Merge upstream/main into main (weekly sync, 2026-09-29)
Summary
The weekly upstream sync that #118 ("Staying in sync", duty 1) requires. It brings fork main level with we-promise/sure a11d671fe: 47 upstream commits since #238. Upstream main has moved 13 commits past that point since the branch was cut. They go in the next sync, so this PR's resolutions stay reviewable as they are.
Merge it with a merge commit, not a squash, per #118 duty 4.
Commits on the branch:
6f8db65e1: the merge of upstreama11d671fe(22 conflicting files, resolved as below).604fdb698: keeps the fork's loan engine in every file upstream we-promise/sure#3474 touched.35957f9ca: moves the retirement plan migration off upstream's version number.df958ee5e: mergesmainat7086ebd3a, which brings in #259.
Scope and dependencies
- Issue: #118 (weekly sync duty). The reminder that should stop syncs slipping is #263.
- Parent PR/branch, if stacked: none. Base is
mainat7086ebd3a. - Intentionally out of scope:
- The 13 upstream commits after
a11d671fe. - Moving the fork's loan schedule table onto upstream's new
DS::Table(we-promise/sure#3805). See below.
- The 13 upstream commits after
Conflicts and resolutions
Shared files, merged on their merits (6f8db65e1):
- Upstream's
:uncategorizedactivity filter (we-promise/sure#3797) is kept beside the fork's extra-payment params. - The fork's
PERMISSION_LEVELStable is kept. It already gives:annotatethe meaning upstream adds. - Both sides' tests are kept in the account, transaction and market-data importer tests.
Upstream we-promise/sure#3474 (loan payoff projection and chart): the fork's side, everywhere (6f8db65e1 and 604fdb698). This follows #184's decision that the fork keeps its own loan engine.
-
The first merge resolved only the conflicting hunks that way. we-promise/sure#3474's files that merged without conflict came in whole, including upstream's
Loan::PayoffChartand its tests. They call methods only upstream's engine has (Loan#origination_date, aprojectionlocal on the schedule tab), so 45 tests errored. -
604fdb698puts every file we-promise/sure#3474 touched back to the fork's version. It removesapp/models/loan/payoff_chart.rbandtest/models/loan/payoff_chart_test.rb, which exist only upstream. -
It then replays the other upstream commits in this sync that touched the same files, so none of them is lost:
Upstream commit File(s) 261350a7c(we-promise/sure#3797, uncategorized filter)accounts_controller.rband its testa9d82a97d(tag preload)accounts_controller.rbf2785fe5a(period picker)period_picker.html.erb, its test,accounts_controller_test.rba83321c1ctest/i18n_test.rb -
Not replayed:
b6ba9c57e(we-promise/sure#3805), which moves four hand-built tables ontoDS::Table. One of them is the loan schedule table. The fork's schedule table carries rate-change markers that upstream's lacks, so its hunk doesn't apply. Moving that table ontoDS::Tableis fork UI work, not a sync resolution. The other three tables are unaffected. -
After
604fdb698, we-promise/sure#3474's 29 files differ from forkmainonly by the replayed changes above.
The migration version collision (35957f9ca):
- The problem. Upstream's
20260928090000_normalize_trade_republic_activity_labelsand the fork's20260928090000_create_retirement_plansshare a version, so the merged tree couldn't load (DuplicateMigrationVersionError). - The renumber. The fork's migration becomes
20260928090100, still before the two fork migrations that alterretirement_plans. Itscreate_tableand three check constraints useif_not_exists. - The re-run. A database that already ran the fork's migration has
20260928090000recorded, so it would treat upstream's normalisation as done and skip it for good. The new fork-only20260930090000_rerun_trade_republic_activity_label_normalizationruns it once more. It is idempotent: the translated labels it maps are gone after one run, and the labels it clears are already NULL.
Schema regeneration (duty 2)
The committed db/schema.rb is the merged schema with the version stamp moved to 2026_09_30_090000. It was checked, not taken on trust:
- I loaded fork
main's schema into a scratch database and seeded it, then randb:migratewith this branch. - The resulting dump differs from the committed file in three check constraints only (
financekit_lineage_account_origin,chk_retirement_plan_streams_kind/_source,chk_retirement_plans_mode). There, this local PostgreSQL printsARRAY['a'::character varying::text, …]in place ofARRAY[…]::text[]. The constraints are the same, and the committed file keeps the parents' form, as #238 did.
New upstream migrations in this sync:
20260927160000_add_brokerage_account_id_to_trade_republic_items20260927161700_backfill_brokerage_account_id_on_trade_republic_items20260928090000_normalize_trade_republic_activity_labels20260928180000_add_otp_last_used_at_to_users
Evidence checklist
- Each issue in this PR has its own acceptance criteria and no unrelated issue work is included. This is a sync, plus the two resolutions it needed.
- Contract rows touched by this change name existing tests. (Not applicable: the fork's loan engine and its contract are unchanged.)
- Any gate test has an observed failing mutation transcript attached. (See the migration mutations under Validation.)
- Fixtures used as evidence assert internal consistency. (Not applicable.)
- Financial calculations use
BigDecimaland documented rounding points. (Not applicable.) - De-identification uses token-shape allowlists; no personal data is included.
- Files changed, decisions, tests/runtime, risks, and next unblocked issue are documented below.
Validation
Local runs used Ruby 3.3.6 with the 3.4.9 pin overridden locally, because 3.4.9 can't be installed here, and PostgreSQL 16. CI is authoritative.
Full bin/rails test, before and after the fixes:
- At
6f8db65e1(the first merge, now loadable with the migration fix applied): 11,263 runs, 8 failures, 48 errors. Of those, 7 were environmental, 4 were the month-end loan tests that #259 fixes, and about 45 were the we-promise/sure#3474 breakage above. - At
df958ee5e: 11,228 runs, 48,633 assertions, 4 failures, 3 errors, 33 skips. All 7 are this environment's known failures, the same 7 as on unmergedmainhere:Provider::RegistryTest(Anthropic env)Provider::OpenaiTest(Ruby 3.3Hash#inspect)- three
Settings::HostingsControllerTestAnthropic base-URL tests ActiveStorageAuthorizationTestandAdmin::UsersControllerTest(no image processor)
Migration simulation. I built a scratch database from fork main's schema, which has 20260928090000 recorded as the retirement migration. I seeded it with a retirement plan and two Trade Republic transactions labelled Storting, one on a cash account and one on an investment account. Then I ran db:migrate with this branch:
- Before
35957f9ca: it fails withActiveRecord::DuplicateMigrationVersionError. - After: it runs the five pending migrations:
20260927160000,20260927161700,20260928090100,20260928180000and20260930090000. The retirement plan row and all nine constraints survive. The labels becomenilon the cash account andContributionon the investment account, which are upstream's intended values. - Mutation, without the re-run migration: the migration completes with nothing pending, but both labels stay
Storting. That is the silent failure20260930090000exists to prevent. - Mutation, without
if_not_exists: the migration aborts, because the table already exists. - Same process: with
20260928090000unrecorded, the normalisation and the re-run both execute in one migrate. There's no double-load warning, and the second pass changes nothing.
Linting and security:
bin/rubocop: 2,945 files, no offenses.bin/brakeman --no-pager -q: 0 warnings.erb_lint --lint-all: 2 autocomplete offenses inapp/views/loans/_form.html.erb(lines 104 and 108). That file is identical onmain, which reports the same offenses. This PR doesn't touch the file, so it is left out of scope.
Risks, blockers, and follow-up
- we-promise/sure#3474 may carry fixes the fork's engine lacks. Upstream's payoff projection went through its own review. Comparing it with the fork's engine for anything worth adopting belongs with #184, not this sync.
- The fork's schedule table isn't on
DS::Table(we-promise/sure#3805). That's fork UI work, if wanted. - Deployments: on a database that ran the fork's retirement migration,
20260930090000normalises Trade Republic labels once when this deploys. It changes onlytrade_republicentries whose label isn't locked, user-edited or set by an enrichment, which is upstream's own rule. - Next: the remaining 13 upstream commits; then reconcile #258's pending-SQL files with the pre-flight on this base, per #262.