Store a card's intro APR expiry and step-up rate #1025
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
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
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1025"
general
weight: 0.35
jaysbeekay
Fixes jaysbeekay/sure#904
Upstream issue: we-promise/sure#5445
Upstream PR: not opened yet; same branch, same commit.
Stack: base
up/card-minimum-percent(jaysbeekay/sure#1024) ← jaysbeekay/sure#1023 ← jaysbeekay/sure#1022 ← jaysbeekay/sure#1021 ← jaysbeekay/sure#1020 ← jaysbeekay/sure#1006. Sibling: fork #1009's daily-rate slice (another branch on #1006) edits the same APR tile's "Monthly rate" row; expect one small textual conflict there.Summary
A card can now record an introductory rate as one dated step. The
aprcolumn holds the intro rate, labelled Intro rate on the form while an end date is stored. Intro rate ends on is when it stops, and Rate after the intro applies from that date. Every APR reader uses the rate in force on its own date, so interest no longer runs on at the teaser rate past the expiry. Clearing the end date makes the rate after the intro the card's APR. Per the revised plan, the chart step moved to the payoff projection (jaysbeekay/sure#903).What changed
CreditCard#effective_apr(on:):aprbeforeintro_apr_expires_on,after_intro_aprfrom that date itself.config/locales/models/credit_card/en.yml): an expiry needs a step-up rate, a step-up rate needs an expiry, and an intro needs anapr; the step-up rate is ≥ 0.before_validation :end_intro_rate: a save that clearsintro_apr_expires_onwhile a rate after the intro is set moves that rate intoaprand clearsafter_intro_apr, so an ended intro can be removed without falling back to the intro rate. Every other save stores the rates as typed. The intro days of an open cycle keep the intro rate after the expiry (a new rate after the intro saved on 1 Oct still gives 7.40 for the 11 Sep–10 Oct cycle; re-pricing those days would give 14.79).aprin app/ — every one is listed):-
cycle_interest_money(#1006): each day charged at that day'seffective_apr(cycle_balance_days→cycle_rated_balance_days), still summed then rounded once. #1006's comment "the current APR applies to the whole cycle" is updated.-
StatementSummary#monthly_rate:effective_apr(on: as_of) / 12.- Overview APR tile:
effective_apr(on: today)and "Until <date> (n days), then <rate>" while the intro runs;show_aprstill keys onapr.-
GetAccounts#credit_card_terms:apris the rate onas_of_date;after_intro_aprandintro_apr_expires_onadded.-
PlaidAccount::Liabilities::CreditProcessor#write_apr, throughenrich_attribute(..., source: "plaid"):- while an intro runs, Plaid's APR is skipped, so the intro rate stays;
- once the intro has ended, Plaid's APR is written to
after_intro_apr, so the days before the expiry keep the intro rate;- with no intro, it overwrites
apr(ignore_locks: true), as main does for every Plaid card field;- the APR is the
aprsentry whoseapr_typeispurchase_apr, or the first entry when none is;- a nil APR changes nothing;
- the card is restored and its errors are cleared before the write, so a refused minimum or cycle update cannot stop it, and an APR the model refuses is logged against the Plaid connection ("Plaid card APR refused by the model").
Plaid reports no expiry, so the expiry has no provider writer.
- Left alone:
RedbarkAccount::CreditCardDetailsProcessor(already fills only a blank, unlocked APR); the form/controller/importer (they carry the column).aprfield is labelled "Intro rate" when an end date is stored (it follows the stored date, so a refused submit does not relabel it) and "APR" otherwise. Every field stays editable. The fields are permitted and carried by the importer.GetAccountsdescription:apris the rate in force on the date asked, and it says whatafter_intro_aprandintro_apr_expires_onmean.Tests (red on #1024: 9 errors
unknown attribute 'after_intro_apr'/undefined method 'effective_apr', 1 failure no form input)test/models/credit_card_test.rbaccounts_controller_test.rb: on 6 Dec the tile shows 0.000% and "Until January 05, 2027 (30 days), then 22.900%"; on 5 Jan it shows 22.900% and no intro line.get_accounts_test.rb:apr0 withafter_intro_apr22.9 and the date; on the expiry dateapr22.9.plaid_account/liabilities/credit_processor_test.rb: "keeps the intro APR while the intro rate runs" (0 survives a sync reporting 15; minimum still updated).credit_cards_controller_test.rb,data_importer_test.rb: form saves both; round trip.Added after the Gatekeeper review (each failed first as noted, or is a guard caught by a mutation):
credit_card_test.rb:- "an intro rate needs an APR";
- "the step-up rate cannot be negative" (−0.01 refused, 0 valid);
- "clearing the intro's end date makes the rate after the intro the APR" (before:
RecordInvalid) and its guard "clearing the intro's end date and its rate after keeps the APR";- "after the intro has ended, a new APR is saved as the intro rate" (before: 0.0, expected 1.9);
- "a new APR while the intro runs keeps the intro rate", "after the intro has ended, a save that leaves the APR alone keeps the intro rate", "an APR saved with its intro fields keeps them after the expiry";
- "a new rate after the intro saved after the expiry keeps the cycle's intro days at the intro rate" (7.40).
credit_cards_controller_test.rb:- "the edit form offers the intro rate and saves it" now sends
apr: 0and asserts the APR is locked, which ties a form save to the lock;- "clearing the intro's end date in the form makes the rate after the intro the APR" (before: 422);
- "after the intro has ended, the edit form still edits the intro rate and the rate after it";
- "an intro rate entered after the intro has ended is saved as given";
- "a card without an intro rate edits its APR";
- "a refused first intro rate re-renders the form with the APR label".
credit_processor_test.rb:- "keeps the APR when Plaid sends none";
- "after the intro has ended, takes Plaid's APR as the rate after the intro" (before: 0.0, expected 24.9);
- "overwrites a locked APR when no intro rate runs, as for the other Plaid card fields" (before: 15, expected 27.9);
- "takes the purchase APR from Plaid's list" and "takes Plaid's first APR when none is a purchase APR";
- "an APR the model refuses is logged against the Plaid connection";
- "an unchanged APR is not logged as refused after another attribute failed";
- "Plaid's APR saves on its own after the other card fields are refused" (before: a numeric overflow raised out of the sync).
get_accounts_test.rb: "describes a card's APR in force and its intro rate keys".Mutations (each alone)
| # | Mutation | Caught by |
|---|---|---|
| M1 | step-up the day after expiry | effective APR, cycle interest |
| M2 | cycle interest at the column APR | cycle interest 7.40 |
| M3 | monthly rate from the column | summary monthly rate |
| M4 | expiry without rate accepted | validation |
| M5 | rate without expiry accepted | validation |
| M6 | tile reads the column | Overview |
| M7 | intro line after expiry | Overview |
| M8 | GetAccounts reads the column | GetAccounts |
| M9 | Plaid writes the APR while the intro runs | "keeps the intro APR while the intro rate runs" |
| M10 | Plaid APR not written | 2 Plaid tests |
| M11 | not permitted | form test |
| M12 | dropped from importer | round trip |
| M13 |
unless apr.nil?removed | keeps-when-none || M14 |
accountable.lock_saved_attributes!dropped | form lock assertion || M15 | step-up
>= 0dropped | cannot-be-negative || M16 |
aprnot required with an intro | intro-needs-an-APR || M17 |
end_intro_ratewithout the nil guard, or without moving/clearing the rate | the clearing tests || M18 |
end_intro_ratefires on any expiry change, or whenever the expiry is nil | form intro test and 7 others; validation and Plaid log tests || M19 | Plaid always writes
apr| after-the-intro Plaid test || M20 |
restore_attributesdropped before the write | saves-on-its-own test || M21 | label always "APR", or from the submitted date | the two label tests |
Verification
19642 runs, 0 failures, 8 errors(8ReleaseNotesWorkflowTesterrors, nonode). Targeted card, Plaid, importer, assistant and Redbark files:652 runs, 0 failures, 0 errors.accounts_test(it fills "APR" on card creation): 12 runs, 0 failures.bin/rubocop: no offenses.erb_lint(2 files): no errors.bin/brakeman: 0 warnings.Screenshots
Same seeded card with APR 0% (the intro rate). Before (#1024): nothing says the 0% ends. After: 24.9% from 40 days out, shown on the APR tile. Before = #1024.
| View | Before | After |
|---|---|---|
| Overview — light, desktop | !before | !after |
| Overview — light, phone | !before | !after |
| Overview — dark, desktop | !before | !after |
| Overview — dark, phone | !before | !after |
| Edit form — light, desktop | !before | !after |
| Edit form — light, phone | !before | !after |
| Edit form — dark, desktop | !before | !after |
| Edit form — dark, phone | !before | !after |
After the Gatekeeper review fixes (262d65aae): the edit form for a card whose intro ended 20 days ago (intro 0%, rate after 24.9%). Both rates are labelled and editable, and the hint says how to clear the intro. On the reviewed head (d2e59ca39) the same two fields were labelled "APR" and "APR after the intro rate".
| View | After |
|---|---|
| Edit form, intro ended — light, desktop | !after |
| Edit form, intro ended — light, phone | !after |
| Edit form, intro ended — dark, desktop | !after |
| Edit form, intro ended — dark, phone | !after |
Migration notes
20261128120400_add_intro_apr_to_credit_cards:intro_apr_expires_ondate andafter_intro_aprdecimal(10,2), both nullable; existing rows NULL (no intro,effective_apr=apr).Blast radius
cycle_interest_money→statement_summary.estimated_interestand the helper's wording: a card without intro fields multiplies by the sameaprevery day, so the sum is unchanged (all #1006 interest tests unchanged).end_intro_ratefires only on a save that clears the end date.Family::DataImporterbuilds new cards only, where the expiry goes nil → nil, so it never fires there.Enrichable#enrich_attributesreadslocked?before its transaction, so a lock saved mid-sync can still lose to that sync. The code is shared by everyenrich_attributecaller and is left alone here. Plaid's APR path reads no lock: it skips the APR while an intro runs and passesignore_locks: trueotherwise.