Merge upstream/main into main (weekly sync, refreshed 2026-10-22)

Merged
JA
1mo ago
+54159-7273

Fork issues this sync closes

Each fix below is upstream's and reaches fork main with this merge.

Closes jaysbeekay/sure#235 (members see unshared provider accounts; we-promise/sure#4046, #4048, #4050, #4052)
Closes jaysbeekay/sure#350 (Enable Banking broadcasts the admin panel; #4044)
Closes jaysbeekay/sure#386 (provider generator views raise NameError; #4099)
Closes jaysbeekay/sure#388 (a null byte in a rule gives a 500; #4089)
Closes jaysbeekay/sure#389 (widening an email rule emails history; #4150)
Closes jaysbeekay/sure#416 (unknown or NUL rule types give a 500; #4175)
Closes jaysbeekay/sure#417 (rejected statement hidden from the vault; #4299)
Closes jaysbeekay/sure#422 (destroy_later leaves pending_deletion; #4172)
Closes jaysbeekay/sure#426 (failed deletion leaves pending_deletion; #4173)
Closes jaysbeekay/sure#435 (re-enabling an email rule emails history; #4089)
Closes jaysbeekay/sure#445 (Apply all emails for switched-off rules; #4211)
Closes jaysbeekay/sure#455 (holding copy-forward duplicates; #4260)
Closes jaysbeekay/sure#481 (Enable Banking sends a LAN IP as the PSU IP; #4304)

jaysbeekay/sure#188 (loan day-count) stays open until the next sync brings in #3639.


Refreshed 2026-10-22 (head 4c88ec0af)

CommitWhat
950539719Merge fork main (jaysbeekay/sure#471: extra repayment amount and Apply on one row). Clean.
a527a62b2Merge upstream main up to be6ba16b6 (#3502), 28 first-parent commits including #3899, #3956, #3974, #4306, #4239 and #3952.
be88762d2Two goal tests aligned with multi-currency funding (#3974) and the fork's explicit progress basis (jaysbeekay/sure#299).
b1797c160The stale valuation tests use the deterministic Insight::BodyWriter from #4239.
5313a6c7eRemoves the fork's duplicate Family#earliest_activity_date (same query as upstream's from #4007; Ruby kept the second). family.rb now matches upstream there. The callers' tests ran 115 times with 0 failures.
28ba316f1Cherry-pick of jaysbeekay/sure#516: the four CI service images move from ECR Public to mirror.gcr.io. test_system failed on toomanyrequests: Data limit exceeded before any test ran (job 119767157404).
2cc6e0b4btest_unit gets timeout-minutes: 15 (fork-local). On 5313a6c7e the unit step passed in 8 min 29 s, and then upstream's Encryption tests step was cancelled at the 10-minute cap (job 119767156899).
4c88ec0afThe fork's session_expires_at migration test runs in a transaction. It used to commit the drop and re-add of the column, which moved it to the end of trade_republic_items and left other pooled connections with stale prepared statements: 131 cached plan must not change result type errors on 2cc6e0b4b (job 119884001299, order-dependent). Details in comment 6349511246.

Deferred (owner decision): upstream d647b0430 (#3639, loan day-count conventions) and the 15 commits after it wait for the next sync, because jaysbeekay/sure#478 converges the fork's loan code on upstream's first. This refresh stops at be6ba16b6, the first-parent commit before #3639, and no loan files conflicted.

Resolutions

  • Redbark: the fork's RedbarkAccount::LoanDetailsProcessor and its test are kept. Upstream's version needs Loan::MAX_INTEREST_RATE and Loan::Simulator::MAX_PERIODS, which the fork's engine lacks. The constructor is identical, so #3956's processor call fits. Comment-only hunks take upstream's text, in app/models/provider/redbark.rb, app/models/redbark_account/processor.rb, app/models/redbark_item.rb, app/models/redbark_item/importer.rb, app/models/redbark_item/syncer.rb, test/models/redbark_account/processor_test.rb, test/models/redbark_item/importer_test.rb and test/models/redbark_item/syncer_test.rb. Compared with git merge-tree --write-tree 950539719 be6ba16b6, the only non-comment lines that differ in those eight files are the conflict markers. processor_test takes upstream's family-currency setup, and redbark_account_test keeps both sides.
  • Duplicate migration: the fork's 20260921120000_add_raw_account_details_payload_to_redbark_accounts is removed, and upstream's 20261003090000 adds both columns with if_not_exists: true.
    • Verified on a fresh database (migrate from zero) and a fork-state database (prior schema loaded, then migrate). Both dump to the committed schema.rb unchanged, and migrate:redo works.
    • Fork databases keep an orphan 20260921120000 row in schema_migrations, which is harmless. db:migrate:status lists it as NO FILE.
  • Goals:
    • Both conflict sides are dropped: linked_accounts_must_match_goal_currency, which upstream removed in #3974, and default_progress_basis_for_investment, whose before_save the fork removed in jaysbeekay/sure#299.
    • The 13 goal locales keep the fork's must_be_fundable wording, which includes crypto, and drop currency_mismatch.
    • docs/llm-guides/goals.md merges upstream's multi-currency text with the fork's basis rules. Upstream's "investment-backed goals default to contributions" is removed, because it's false on the fork.
  • Insights: upstream's action wrapper and "Dig in with AI" link, keeping the fork's frame: action[:frame]. Both sides' controller and helper tests are kept.
  • users_controller: permits both investment_contributions_as_spending and stale_valuation_days.
  • schema.rb: version 2026_10_20_090000, the latest migration present.
  • ci.yml: upstream's Encryption tests step and test_system's 20-minute cap are taken. The fork keeps its extra jobs, takes the mirror.gcr.io images from jaysbeekay/sure#516, and raises test_unit to 15 minutes, because the fork's 14,306-run suite plus the Encryption step does not fit in upstream's 10.

Checks

  • CI on 4c88ec0af: every check green, test_unit and test_system included.
  • Full suite at 4c88ec0af, CI's seed 37714: 14,306 runs, 66,485 assertions, 0 errors, 38 skips locally; 1 failure, Provider::OpenaiTest extra_headers, which fails only because the sandbox runs Ruby 3.3 (it asserts Ruby 3.4's Hash#inspect). Earlier, at 5313a6c7e: 14,306 runs, 0 failures, 0 errors, 38 skips locally (CI: 66,483 assertions, 39 skips).
  • RuboCop on 132 changed Ruby files: no offences. erb_lint on 29 changed ERB files: clean. Brakeman: 0 warnings.
  • db:migrate on a fresh database and on a fork-state database both reproduce db/schema.rb exactly.

Updated 2026-10-22 (head 79828da19): the rule migration fails closed

This answers nightly review 6303688941 (20 Oct). The BLOCKER was that a pair of rules forming both a chain and a conflict had its outcome silently changed. The owner chose option A, fail closed.

CommitWhat
79828da1920261015090001 stops before writing anything when a pair of active rules can't keep its outcome; down is irreversible.

Behaviour now:

  • An unkeepable pair stops the migration. up ranks every family first. If any pair of active rules both set a field while a chain holds them in the fork's order, it raises ActiveRecord::MigrationError before writing. The message lists each pair per family (ids, names, the field both set, and each hop of the chain) and says how to fix it: edit, disable or merge one of the two, then run bin/rails db:migrate again. priority and every rule's position are left as they were.
  • What has already run: upstream's 20261006140000 committed in its own transaction, so position holds its provisional A–Z order until the rerun succeeds.
    • The Docker web container won't start meanwhile, because its entrypoint runs db:prepare. The message says to edit rules from bin/rails console.
    • Sidekiq has no migration step, so the message says to stop it until the migration succeeds. No app-side guard is added (owner decision).
  • Inactive rules can't stop it (owner decision). They take no part in automatic runs, so their edges go in after the active rules' and are dropped where they would close a cycle. This is what makes "disable one of them" a working fix.
  • down raises IrreversibleMigration. position doesn't record which pairs were kept for a chain, so the fork's priority can't be rebuilt; restore a backup taken before the migration ran.

Checks at 79828da19:

  • Migration tests: 12 runs, 51 assertions.
    • The new tests failed against the previous migration.
    • Five mutations each fail a test: no raise, raise after writing, inactive rules counted, inactive edges added first, chain missing from the message.
  • Full suite: 14,092 runs, 0 failures. RuboCop and Brakeman: clean.
  • Real database:
    • Seeded with a chain-and-conflict pair, db:migrate exits 1. 20261006140000 has run, 20261015090001 is still pending, and priority is intact.
    • After disabling one rule from the console, db:migrate succeeds.
  • The demo database has no rules, so this stop cannot fire there.

In the 15 Oct section below, the chain-and-conflict paragraph, the Down paragraph and the test list are superseded by this section.


Refreshed 2026-10-20 (head 40c4be22c)

Upstream main merged again at 9884e617b, five more commits: we-promise/sure#4299 (rejected statements stay in the vault inbox), #4177 (an investment transfer counted as a plain transfer), #3987 (category structure lock), #4089 (rule text operators) and #4235 (cache invalidation on currency change and account deletion).

CommitWhat
1ab736326Merge upstream main. 11 conflicted files, resolved as below.
40c4be22cUpstream's new currency cache test given the fork's totals shape (fees).

Conflict resolutions in 1ab736326:

  • The rule operator files (Rule, Rule::Action, Rule::Condition, Rule::ConditionFilter, Rule::SafeRegex and three test files): fork main carried an earlier version of #4089. Upstream's merged version is taken throughout. It is a superset here, already holding the ordered-run and timeout tests.
  • IncomeStatement#family_stats and InvestmentStatement#totals_query cache keys: the fork's extra parts (excluded kinds, date range, totals_query/v5) kept, with upstream's cache_freshness_key and family.currency from #4235.
  • investment_statement_test: both sides kept.

Checks:

  • Full suite at 1ab736326: 14,090 runs, 0 failures, 1 error, which was the stub fixed in 40c4be22c. The investment and income statement tests then ran 172 runs, 0 failures. Dropping family.currency from the totals key fails the new test.
  • The earlier test_system failure was Docker Hub rate-limiting the image pull (toomanyrequests), not a test.
  • The 11 code-scanning threads are answered and resolved as false positives. The CSS and both controllers are identical upstream. The holding.rb SQL interpolates only a constant fragment and a sanitised bind.

Refreshed 2026-10-18 (head faa3f52c2)

The branch now also carries today's fork main (67dea25b2, after jaysbeekay/sure#433, jaysbeekay/sure#432 and jaysbeekay/sure#359 merged) and upstream main at e913d1d71 (77 more upstream commits). Merging both brings in the upstream fixes for jaysbeekay/sure#462, jaysbeekay/sure#445, jaysbeekay/sure#416, jaysbeekay/sure#426, jaysbeekay/sure#422, jaysbeekay/sure#386, jaysbeekay/sure#235, jaysbeekay/sure#455, the Bills part of jaysbeekay/sure#467, and jaysbeekay/sure#350.

CommitWhat
79b29324aMerge fork main (clean).
2ea8d2867Merge upstream main. 16 conflicted files, resolved as below.
a0f70dc57Fork migration renumbered to 20261015090001, plus guarded 20261018090000.
faa3f52c2Restores a fork period test the resolution had spliced with upstream's tail.

Conflict resolutions in 2ea8d2867:

  • Account.create_and_sync: the loan's start date dates the opening anchor only when it is on or before today (fork, jaysbeekay/sure#432) and after Entry.min_supported_date (upstream, we-promise/sure#4174). The fork's Loan does not yet reject a future start date, as upstream's does. For the same reason, upstream's test "create_and_sync rejects a loan with a future start date" is left out; jaysbeekay/sure#478 brings the validation.
  • Account private methods, HoldingsController (includes(:account, :security)), IncomeStatement (upstream's new daily expense methods plus the fork's family_stats signature), the loans locale (both sets of keys, one duplicate pair dropped): both sides kept.
  • SnapTrade data_helpers and holdings_processor: upstream's version, a superset of the fork's (adds provider_row for remapped holdings), with its tests.
  • period.rb: comment only; upstream wording.
  • family_test and period_test: the fork's tests for the earliest-activity anchor, which cover upstream's cases and more. Upstream's non-conflicting tests are kept.
  • Cargo.lock: upstream.

Migration version collision. Upstream's 20261015090000_add_session_expires_at_to_trade_republic_items has the same version as the fork's rule migration, so nothing could migrate. A fork database (the demo included) has already recorded 20261015090000 for the fork's migration.

  • The fork's migration is now 20261015090001. It returns early once rules.priority is gone, so it runs again as a no-op.
  • That database would also skip upstream's column, so the fork-only 20261018090000_ensure_trade_republic_session_expires_at adds it when missing. Tested both ways.

Verification at a0f70dc57 plus the test fix:

  • Full suite: 13,996 runs, 0 failures. The single error was the spliced period test, fixed in faa3f52c2; its file and the migration tests then ran 97 runs, 0 failures.
  • RuboCop (3,193 files) and Brakeman: clean.

Still merge with a merge commit, not a squash. The sections below describe the 15 Oct sync; where they name 20261015090000_convert_rule_priority_to_position, read 20261015090001.


Summary

Brings jaysbeekay/sure's main up to we-promise/sure's main head (a3bb5d991, "2883: Fix unidentified card holds", we-promise/sure#4162). Fork main (8d4842986, after jaysbeekay/sure#429) was 125 commits behind; the merge base is eb34c06f0, the head jaysbeekay/sure#332 merged. mirror/upstream-main is at the same upstream commit.

Owner-approved weekly sync. It also carries the jaysbeekay/sure#448 port, as that issue's order A requires (jaysbeekay/sure#384 merged first, as 6e97cdf05).

Head branch: sync/upstream-2026-10-15

Commits on the branch:

CommitWhat
679c16725The merge. Parents 8d4842986 (fork main) and a3bb5d991 (upstream). 91 conflicted files, each listed below.
9082f803cThree fork tests stored a zero exchange rate to reach the conversion guards; we-promise/sure#3790 now refuses one in the model and the database. The guards stay, and the tests hand them the rate directly.
4ac18ac4eRecords that investment income is now summed signed (we-promise/sure#4082): methodology P24/P26, the contract gate, and the cache-key test at totals_query/v5.
ab3f8a127Fork-only migration 20261015090000: carries each family's rule outcome from priority into position, then drops priority.
eafa42835, 948a0175e, 390d47330jaysbeekay/sure#448's port, cherry-picked from up/net-contributions-model (f87a751af, 8fc7f6aed, 1fb0df306).
2da501fe2A stale-valuation card is expired by status, not through Insight.visible, which we-promise/sure#4061 made hide exactly the card that removing a share must expire (found by the full suite).
821b548c5A fork FinanceKit test still counted the retired ApplyAllRulesJob; the downstream now queues ApplyRulesJob (we-promise/sure#4013).
9bbcc19acThe rules rake test (from we-promise/sure#4013) loads only rules.rake, so it no longer flakes on test order (comment 6211978487).
80ce7dfdaThe rule-order migration keeps dependent chains in the fork's order and reverses only conflicts (see below; answers the 15 Oct nightly review).

Merge it with a merge commit, not a squash, per jaysbeekay/sure#118 duty 4.

Rules ordering: owner decision, option A (converge on we-promise/sure#4013)

The two designs could not both stand:

Fork (jaysbeekay/sure#292)Upstream (we-promise/sure#4013)
Columnrules.priority (20261001090000, seeded by created_at)rules.position + stop_processing (20261006140000, seeded A-Z by name)
OrderRule.prioritised: (priority, created_at, id) ascendingRule.ordered: (position, created_at, id) ascending
Who wins a contested fieldthe last rule (each overwrites the one before)the first rule (it claims the field)
RunnerApplyAllRulesJob(active_only:, ignore_attribute_locks:)Rule::Runner, ApplyRulesJob after sync, ApplyAllRulesJob from the page
UIup/down arrows, priority sortdrag to reorder (reorder_rules_path), "Stop processing" switch

This PR takes upstream's design everywhere and retires the fork's priority code: the prioritised scope, assign_priority, Rule#move and MOVE_DIRECTIONS, Rule.apply_in_priority_order, the move action and route, the up/down arrows, the priority sort and direction toggle, the "lower one wins" hint, the priority API field, the importer's rules_priority_base, and test/models/rule/priority_test.rb. A final git grep for prioritised, apply_in_priority_order, assign_priority, move_rule, rules_priority, priority_hint and "lower one wins" across app, lib, config, test, spec and docs returns nothing.

Kept (fork-only, unrelated to ordering): the starts_with, ends_with and matches_regex operators and Rule::SafeRegex (both on fork main since jaysbeekay/sure#292). Upstream made Rule#matching_scope public and the runner calls it once per rule, so the regex is resolved there, under the statement timeout, and handed on as ids through scope_for_transaction_ids (an array parameter, not a bind per id). The display counts still read a timed-out pattern as zero. The fork's per-apply @regex_matches memo is gone: apply now receives its scope once from the runner.

Parity of the runs: the nightly pass was ApplyAllRulesJob(active_only: true, ignore_attribute_locks: false) and is now ApplyRulesJob (active rules, locks respected). "Apply all" was ApplyAllRulesJob (every rule, locks ignored) and still is.

The migration: 20261015090000_convert_rule_priority_to_position (fork only)

Upstream's migration numbers existing rules A-Z by name. On a fork database that can change which rule wins, or break a chain of rules. This migration runs after it and renumbers each family's rules pair by pair (80ce7dfda, answering the 15 Oct nightly review, comment 6204131222):

  • A chain keeps the fork's order. One rule writes a field another rule's conditions read: name (transaction_name), category, merchant, tags, or kind (a transfer, read by transaction_type). Both runners let a rule see what earlier rules wrote, so the two run in the order they ran on the fork. This covers a rename followed by a rule matching the new name, and the mirror case: a rule that matched a name before a later rule renamed it.
  • A conflict is reversed. Both rules set the same field (the fields upstream's runner claims: name, category, merchant, excluded, transfer, investment activity label). The fork's last writer won; it now runs first, where it still wins.
  • Anything else is reversed, so a family with no chains gets the exact reverse of the fork's order, as before.

It is a topological sort: chain edges always point forward in the fork's order, so they never form a cycle, and a conflict edge is added only when it does not close one. Among the rules free to go next, the one latest in the fork's order goes first. Compound conditions are read through their sub-conditions. auto_categorize and auto_detect_merchants run in background jobs after the run, so they create no chain.

A pair that is both a chain and a conflict (B matches A's rename, and both set the category) cannot keep both. Superseded 22 Oct: the migration now stops before writing anything and lists each such pair (see the section at the top).

Down raises IrreversibleMigration (superseded 22 Oct; see the top section).

Proof (test/migrations/convert_rule_priority_to_position_migration_test.rb; 12 tests and 51 assertions at 79828da19, where test 7 became "stops the migration and changes nothing" and two tests were added for disabled rules). The test rebuilds a fork database's state: it adds priority back and numbers position A-Z as upstream's migration does. The three original tests (a conflict keeps its winner, every tie-break key reversed per family, down) are unchanged. New:

  1. "a rule matching a name an earlier rule wrote still runs after it". A renames AMZN… to Amazon; B matches amazon and sets Groceries. Under the fork the transaction ends up Groceries (asserted); after the migration ApplyAllRulesJob gives Groceries again. Against the old migration it came out uncategorised (nil): the reviewed bug, reproduced.
  2. "a rule matching a name a later rule rewrites still runs before it": the mirror case, same assertions.
  3. "a conflict is still reversed when a chain holds one of its rules back": rename, then a rule on the account setting Dining, then the matcher setting Groceries. Expected order rename, matcher, middle, and Groceries.
  4. "a chain through a compound condition is kept".
  5. "every written field keeps a chain to the condition that reads it": category, merchant, tags and transfer, each with its reading condition.
  6. "rules with no chain or conflict between them are reversed": two tag rules on the account.
  7. "a chain that also conflicts keeps the chain", and the migration's report names the pair.

Fail-first: tests 1, 2, 4, 5 and 7 were written first and all failed against the old migration. Tests 3 and 6 came after, once the first mutation run showed nothing pinned the conflict edges or the tie-break; the mutations below prove them. Mutations, each on the committed migration and restored with git checkout --:

MutationResult
Drop the mirror direction (writes[j] & reads[i])test 2 fails
Ignore sub-conditionstest 4 fails
Drop conflict edgestest 3 fails
Tie-break forward (ready.min)test 6 fails
No report for an unkept conflicttest 7 fails
Tags not counted as a writetest 5 fails

On real databases (run on the first version of this migration, ab3f8a127, before the chain change; not repeated since).

  • From scratch: db:drop db:create db:migrate on an empty database runs every migration, mine last. A fresh db:schema:dump matches the committed db/schema.rb, apart from how PostgreSQL 16 prints five ARRAY[...] check constraints, which is cosmetic and unchanged here.
  • From the pre-sync fork schema, with rule rows: a database built by migrating fork main (8d4842986, schema 2026_10_08_100000), seeded with two families' rules, then db:migrate on this branch. It ran the 11 upstream migrations, 20261006140000 among them, then 20261015090000.
    • Family A (Alpha p1, Zulu p2 older, unnamed p2 newer, Mike p3) came out Mike 1, unnamed 2, Zulu 3, Alpha 4.
    • Family B (Bravo p1, Able p2) came out Able 1, Bravo 2.
    • priority was gone. db:rollback restored Alpha 1, Zulu 2, unnamed 3, Mike 4 and Bravo 1, Able 2, and migrating again succeeded.
  • A database loaded with db:schema:load from the pre-sync schema.rb cannot be used for this check. Schema load marks every migration file older than the schema version as run, upstream's 20261006140000 included, so position never gets added. Real installs only record the migrations they actually ran, so they are not affected.

Export/import. A pre-sync fork NDJSON export carries priority and no position. Upstream's importer ignores priority and appends such rules in file order.

Conflict resolutions (91 files)

Every file git reported as conflicted, grouped by how it was resolved.

Rules ordering (owner decision: option A, converge on we-promise/sure#4013)

FileResolution
app/models/rule.rbUpstream's: position, assign_next_position (advisory lock), ordered, update_positions!, active_rules_above, scope_for_transaction_ids, apply(scope:, claimed_ids:), public matching_scope. Retired the fork's priority scope prioritised, assign_priority, move, MOVE_DIRECTIONS, apply_in_priority_order and the @regex_matches memo. Kept the fork's text operators and Rule::SafeRegex: matching_scope resolves a regex condition's ids under the statement timeout (through scope_for_transaction_ids, so no bind-per-id), and affected_resource_count / total_affected_resource_count still read a timeout as zero.
app/controllers/rules_controller.rbUpstream's require_non_guest!, ordered index, reorder, render_invalid_rule. Retired move, the priority sort and the sort/direction params. Kept the fork's auto_categorize_estimate delegating to Family#auto_categorize_estimate (the batch suggestion page shares it). config/routes.rb: removed the fork's patch :move member route (merged cleanly, would have pointed at a deleted action).
app/jobs/apply_all_rules_job.rbUpstream's (one Rule::Runner pass, retry_on LockBusy). Retired the fork's active_only: / ignore_attribute_locks: keywords and its own advisory lock.
app/models/family/syncer.rbUpstream's ApplyRulesJob.perform_later(family) (active rules, locks respected: the same inputs the fork passed).
app/models/financekit/downstream.rbSame as the syncer.
app/views/rules/index.html.erbUpstream's drag-to-reorder list. Removed the fork's sort selector and its "lower rule wins" hint, which merged cleanly above the conflict. app/views/rules/_rule.html.erb (merged cleanly with the fork's up/down arrows) taken as upstream's.
app/views/api/v1/rules/_rule.json.jbuilderUpstream's position and stop_processing.
config/locales/views/rules/en.ymlUpstream's order_hint and reorder_rule. Removed the fork's sort_*, priority_hint, toggle_sort_direction, move_up and move_down. Kept the fork's starts_with / ends_with / matches_regex operator labels.
docs/api/openapi.yaml, spec/swagger_helper.rbUpstream's position and stop_processing.
test/controllers/rules_controller_test.rbBoth new tests kept (the fork's cost-estimate test and upstream's "confirm says the active rules above run first"). Removed the fork's six priority/move tests.
test/controllers/api/v1/rules_controller_test.rbUpstream's position assertions.
test/models/family/syncer_test.rbUpstream's.
db/schema.rbVersion and rules table per upstream plus the follow-up migration; the loans hunk keeps the fork's constraints (the fork has no down-payment or insurance columns, jaysbeekay/sure#184). Checked by migrating from scratch: the only difference from a fresh db:schema:dump is how PostgreSQL prints five ARRAY[...] check constraints.
app/models/family/data_exporter.rb, app/models/family/data_importer.rb, test/models/family/data_importer_test.rbUpstream's position / stop_processing export and import. Removed the fork's rules_priority_base and the priority assignment (merged cleanly below the conflict) and its three import tests; also removed the fork's export test for priority in test/models/family/data_exporter_test.rb (upstream's export test asserts position).
test/models/rule/priority_test.rbDeleted: every test exercised the retired priority / move / ApplyAllRulesJob(active_only:) code. The behaviour it pinned is covered by upstream's Rule::RunnerTest (top rule wins, stop processing, failures do not stop later rules, one lock per family) and by the new migration test below.

The fork's own features, converged on upstream's reviewed versions

FileUpstream PRResolution
app/models/security/split.rb (add/add), app/models/holding/portfolio_cache.rb, app/models/holding/reverse_calculator.rbwe-promise/sure#3850Upstream's (QTY_SCALE rounding, split_factor_between, starting_portfolio). All three are now byte-identical to upstream.
test/models/holding/forward_calculator_test.rb, test/models/holding/reverse_calculator_test.rbwe-promise/sure#3850Upstream's added tests.
app/models/holding/cost_basis_tracker.rbwe-promise/sure#4033Upstream's comment.
app/models/balance_sheet/net_worth_velocity.rb, test/models/balance_sheet/net_worth_velocity_test.rb (add/add)we-promise/sure#4083Upstream's (account_start_dates reads balances as well as entries). Identical to upstream.
app/models/portfolio/flow_classifier.rb, test/models/portfolio/flow_classifier_test.rb, test/support/portfolio_flow_test_helper.rb (add/add)we-promise/sure#3557Code identical to upstream; kept the fork's header comments, which point at docs/portfolio/methodology.md and the contract gate that binds these test names.
app/models/investment_statement/totals.rbwe-promise/sure#4082Composed. Upstream's signed income (-SUM(amount), so a reversal or a charge labelled as income reduces it) on the fork's aggregation, which keeps its fork-only fees column, income_or_fee_sql, labels read from Portfolio::FlowClassifier and the classifier's pending rule.
app/models/investment_statement.rbwe-promise/sure#4082Cache key totals_query/v5 (the fork was at v4, upstream at v2): signed income changes what the columns mean.
test/models/investment_statement_test.rbwe-promise/sure#4082Upstream's -120 for the relabelled buy, and its new "income nets by sign" test. Its other three new tests duplicate fork tests of the same name and were not added again, and its duplicate private helpers were dropped (the fork's come from PortfolioFlowTestHelper).
The 24 provider cards (akahu, binance, brex, coinbase, coinspot, coinstats, enable_banking, fio, ibkr, indexa_capital, kraken, lunchflow, mercury, monobank, plaid, questrade, redbark, simplefin, snaptrade, sophtron, trade_republic, trading212, up, wise _items/_*_item.html.erb)we-promise/sure#4046, we-promise/sure#4048Upstream's: visible_accounts: is required, the stale-rate lists are filtered to it, and the comments cite we-promise/sure#3630.
app/components/provider_sync_summary.rb, app/controllers/accounts_controller.rb, app/jobs/indexa_capital_activities_fetch_job.rb, app/jobs/questrade_activities_fetch_job.rb, app/jobs/simplefin_item/balances_only_job.rb, app/models/simplefin_item/syncer.rb, app/models/coinspot_item/sync_complete_event.rb, app/models/kraken_item/sync_complete_event.rbwe-promise/sure#4046, we-promise/sure#4050Comment only: upstream's issue reference.
app/models/enable_banking_item/sync_complete_event.rbwe-promise/sure#4044Upstream's: the panel is no longer streamed to the family.
test/controllers/accounts_controller_test.rbwe-promise/sure#4046, we-promise/sure#4048Upstream's comments and its two new partial-sharing tests; kept the fork's loan helpers (variable_rate_loan_account, on_schedule_loan_account, the extra-repayments helpers).
test/integration/trading212_item_broadcast_render_test.rb (add/add), test/models/kraken_item/sync_complete_event_test.rb (add/add), test/models/plaid_item/sync_complete_event_test.rb (add/add), test/models/ibkr_item/sync_complete_event_test.rbwe-promise/sure#4046Upstream's (passes visible_accounts:; comments).
test/lib/tasks/simplefin_pending_cleanup_test.rb (add/add)we-promise/sure#3557Upstream's; identical to upstream.
test/models/simplefin_item/importer_stale_unmatched_pending_test.rb (add/add)we-promise/sure#3557Kept the fork-only negative test ("does not re-count an entry a previous sync excluded").
app/javascript/controllers/sortable_list_controller.js (renamed from the fork's reports_sortable_controller.js)we-promise/sure#4013Upstream's. Its url and param values already express the fork's url / preferenceKey (param = preferences.<key>_section_order), so the fork's values fold into them. app/views/portfolios/show.html.erb (merged cleanly, still wired to the deleted reports-sortable) now uses sortable-list with preferences.portfolio_section_order and the Reports page's 800 ms hold; test/controllers/portfolios_controller_test.rb and the fork's Reports defaults test assert the new attributes.
docs/api/rails_provider_generator.mdupstream f715e06d5, e76057b43, 4b1d282d9 (the fork's jaysbeekay/sure#176 doc, as reviewed upstream)Upstream's wording.

Composed: both sides kept

FileResolution
app/models/account/market_data_importer.rbUpstream's price windows (we-promise/sure#3888: window.start_date / window.end_date, replacing the fork's end-date logic) plus the fork's import_provider_details(include_classification: true, include_constituents: true) and its comment.
app/models/market_data_importer.rbUpstream's separate Security.online.find_each details pass, calling it with the fork's classification and constituent flags.
test/models/account/market_data_importer_test.rbKept the fork's "asks for classification" test; took upstream's rewritten "caps a sold security at its closing trade" in place of the fork's older version of the same test.
app/models/security.rbKept the fork's taggings, constituents and classification-proposal associations next to upstream's splits.
app/models/plaid_account/processor.rbUpstream's BalanceError plus the fork's as_of reader (loan rate-change dating).
app/views/layouts/application.html.erbThe fork's portfolio_nav_item plus upstream's assistant item gated on assistant_enabled (we-promise/sure#4147).
app/views/properties/tabs/_overview.html.erbBoth: the fork's UI::Account::CollateralPosition, then upstream's Chimnie valuation source and refresh button (we-promise/sure#4135).
test/controllers/properties_controller_test.rbBoth: the fork's collateral tests and upstream's Chimnie tests.
test/controllers/reports_controller_test.rbBoth: upstream's two new tests (the sortable id test, and "index provides the download toasts the desktop app shows", which jaysbeekay/sure#332 flagged as missing since jaysbeekay/sure#185 and now returns).
test/controllers/loans_controller_test.rbKept the fork's offset tests; added upstream's "a create that fails on the opening valuation still re-renders the form" and "a late create failure renders the loan's fields even when the form sent none" (we-promise/sure#3733). Both pass on the fork's loan engine.
test/models/account/provider_import_adapter_test.rbBoth: the fork's updated_at stamping test and upstream's three carry-forward tests, plus upstream's private helpers.
test/models/goal_test.rbBoth: the fork's milestone tests and upstream's colourless-ring test (we-promise/sure#4032).
test/models/snaptrade_account/activities_processor_test.rbBoth: the fork's duplicate-ticker test and upstream's option tests (we-promise/sure#3744).
test/models/trade_test.rbBoth includes, upstream's fee and preload tests. Four upstream tests share a name with the fork's tests of the same behaviour; the fork's versions are kept because they also assert realized_gain_loss_unavailable_reason.

Loans (jaysbeekay/sure#184): fork side kept

FileResolution
app/models/loan/payoff_chart.rb, test/models/loan/payoff_chart_test.rb (modify/delete)Kept the fork's deletion, as jaysbeekay/sure#185, jaysbeekay/sure#232, jaysbeekay/sure#272 and jaysbeekay/sure#332 did. Nothing references Loan::PayoffChart on the merged tree. Known gap: upstream's edits to it (we-promise/sure#4006, the tooltip's principal/interest split) are not taken; the fork's own chart has had the same split since jaysbeekay/sure#209.
app/javascript/controllers/loan_payoff_chart_controller.js, test/system/loan_payoff_chart_test.rbFork's, byte-identical to fork main. Upstream's versions draw Loan::PayoffChart's payload, which the fork does not produce. Upstream's new system test "the tooltip splits a scheduled payment into principal and interest" is therefore not carried; it is the only upstream test name in this range that this merge drops (see Dropped tests).

Other fallout from the merge

  • Zero exchange rates (9082f803c). we-promise/sure#3790 refuses a zero, negative, NaN or infinite rate, both in ExchangeRate and in a database check (20261006210000, which first deletes any such rows). The guards against such a rate stay in Trade and Portfolio::RealizedGains. Three fork tests used to store one to reach them, and now raised during setup. They now hand the guard its rate directly:

    • Trade through preloaded_exchange_rates;
    • Portfolio::RealizedGains (the hub test and the Reports card test) through its rates_by_date batch.

    Mutating either guard to return nil if rate.nil? fails all four of these tests (upstream's own test included).

  • Signed income (4ac18ac4e). Taking we-promise/sure#4082 into Totals changes what the dividends and interest columns mean. So the cache key moves to v5, methodology P24 states the sign rule and binds upstream's netting test, and P26 and its test name the new version. portfolio:verify_contract_coverage (41 + 18 rows) and loans:verify_contract_coverage (16 rows) pass. Mutating the two income sums back to ABS(...) fails two tests.

  • Stale-valuation cards (2da501fe2). The full suite at 390d47330 showed 2 failures, both silent interactions with no textual conflict. The first is AccountShareTest "removing a share expires that account's stale-valuation insight". The fork's Insight.expire_stale_valuation_for! selected through visible, and we-promise/sure#4061 made visible also hide a card about an account no longer shared with every member. So the expiry, which runs after the share is removed, found nothing. It now selects status: [active, read]. A new test, "leaves an acknowledged stale-valuation insight acknowledged", pins the status bound. Mutations: reverting to .visible fails the original test, and dropping the status bound fails the new one. Sibling grep: Insight.visible has no other writer in the fork (the mark-all-read in InsightsController is upstream's).

  • FinanceKit (821b548c5). Financekit::InboxTest "downstream work queues one ordered rules pass" counted ApplyAllRulesJob. It now counts ApplyRulesJob. A sibling grep found no other reference to the retired call shape.

  • Portfolio hub sections. app/views/portfolios/show.html.erb merged cleanly but still pointed at the deleted reports-sortable controller. It now uses sortable-list (see the conflict table).

jaysbeekay/sure#448's port (order A)

jaysbeekay/sure#384 merged as 6e97cdf05 before this sync, so this PR carries the port, as jaysbeekay/sure#448's plan requires.

  • eafa42835 ← f87a751af: the three restatements. On the merged tree, before the cherry-pick, these three failed exactly as jaysbeekay/sure#448 predicted. The value lines were [0, 1900], [0, 900] and [1000, 1900] where the old tests expected [1600, 1900], [600, 900] and [1600, 1900].
  • Fail-first. Before porting the code, I applied the test half of 8fc7f6aed alone. The equal-value test "a linked account whose reset anchor point equals the day's close still opens before the activity" failed with Expected: [1000, 1800] Actual: [1500, 1800]. The rewritten anchor-point unit test also failed ("even when its value differs from the close").
  • 948a0175e ← 8fc7f6aed: Balance::LinkedInvestmentSeriesNormalizer#resets_point_on?, used by normalize, and by Account::Chartable#value_point_before_activity? in place of comparing values.
  • 390d47330 ← 1fb0df306: the normalizer test that pins the supported-start check.
  • All three cherry-picks applied cleanly. chartable_test.rb and linked_investment_series_normalizer_test.rb: 41 runs, 0 failures.

Mutations (jaysbeekay/sure#448's list; each restored with git checkout HEAD --):

MutationCaught by
Chartable reads the reset by value (close.nil? || close.value != point.value)the equal-value test and the anchor-point unit test (2 failures)
resets_point_on? drops the first-activity checkthe resets_point_on? test, "keeps first point when inception comes from holdings", and the chartable "history starts at its holdings" test (3 failures)
resets_point_on? drops the supported-start checkthe resets_point_on? test (1 failure)
The prepended point is not recognised (the builder.balance_series.values.none? disjunct dropped)the anchor-point unit test, which carries the coarse/prepended case (1 failure)

Migrations

Eleven from upstream, in order:

  • 20260927142423 fix Kraken trade entry signs
  • 20260927200000 reset kinds of pending transfer matches
  • 20261003100000 Lunchflow available-credit flag
  • 20261005120000 tool call extra_content
  • 20261006140000 rules position / stop_processing
  • 20261006210000 and 20261006210001: positive exchange-rate check. It deletes non-positive rates, then validates.
  • 20261008090000 rescale Trade Republic bond prices
  • 20261008120000 Trade Republic timeline cursors
  • 20261011090000 Chimnie on properties
  • 20261011151000 Sophtron balance sign override

20260928100000_create_security_splits is identical on both sides, so it is not new here.

One fork-only migration: 20261015090000, above. It must run after 20261006140000, and its timestamp guarantees that. No Gemfile, package.json or workflow changes are in the range.

Dropped tests (jaysbeekay/sure#279 check)

  • Files. I compared the full test/ and spec/ file list against the pre-sync survey (tests-before.txt, 1,261 files). The only file removed is test/models/rule/priority_test.rb, a fork file retired with the priority code. 64 files are added.
  • Test names. I checked every test "..." name in every test file this upstream range adds or modifies against HEAD.
    • All but one of the names missing at HEAD were already missing from fork main before this sync: the loan controller, accounts, system-chart, goal and investment-statement tests removed by the jaysbeekay/sure#184 resolutions since jaysbeekay/sure#185. The jaysbeekay/sure#332 gap "the card preloads the rates its disposals need" also stays missing.
    • The one name this merge drops: test/system/loan_payoff_chart_test.rb "the tooltip splits a scheduled payment into principal and interest" (we-promise/sure#4006). It drives upstream's Loan::PayoffChart, which the fork does not have. The fork's chart has shown the same split since jaysbeekay/sure#209.
  • Gaps closed. "index provides the download toasts the desktop app shows" (Reports), which jaysbeekay/sure#332 flagged as missing since jaysbeekay/sure#185, returns with this merge. So do upstream's two loan create-failure tests (we-promise/sure#3733); both pass on the fork's loan engine.

jaysbeekay/sure#184 check

we-promise/sure#3639 and we-promise/sure#4088 are both still open and unmerged (checked 2026-10-15), so jaysbeekay/sure#184's reconciliation trigger has not fired. The loan files stay fork-side.

Known gaps

  • Upstream's db/migrate/20260916210000_add_down_payment_to_loans.rb and db/migrate/20260916210100_add_insurance_to_loans.rb are left out under the jaysbeekay/sure#184 loan-engine policy: the fork's Loan has no down-payment or insurance columns. They exist only on upstream's side, so a later sync would merge them in cleanly; the next sync must drop them again until #478 converges the loan code.

  • app/models/loan/payoff_chart.rb and its test stay deleted, as in every sync since jaysbeekay/sure#185. Upstream's later edits to them (including we-promise/sure#4006) are not taken.

  • Rule::Runner keys its advisory lock with MD5, as upstream wrote it. The fork moved its own rules lock to SHA-256 for Codacy (jaysbeekay/sure#243) and kept FinanceKit's on MD5 (jaysbeekay/sure#245). Both of those were non-cryptographic uses. This one is left as upstream has it.

  • Biome lint (what CI runs, npm run lint) is clean. biome check also reports format differences in four changed controllers:

    • three are byte-identical to upstream (category_select, plaid, sortable_list);
    • time_series_chart has upstream's comment alignment from we-promise/sure#3906.

    They are left as upstream wrote them.

Local validation

Ruby 3.4.9, PostgreSQL 16 and Redis in private containers, RAILS_ENV=test.

  • Full bin/rails test at the exact head 80ce7dfda: 13,507 runs, 62,505 assertions, 0 failures, 0 errors, 36 skips.

  • Earlier, at 821b548c5, under the cross-track suite lock: 13,500 runs, 62,487 assertions, 0 failures, 0 errors, 36 skips. The first run at 390d47330 had 2 failures (13,499 runs), both fixed by 2da501fe2 and 821b548c5 above.

  • portfolio:verify_contract_coverage and loans:verify_contract_coverage: pass.

  • bin/rubocop: 3,153 files, no offenses.

  • bundle exec erb_lint on the 97 ERB files this PR changes: no errors.

  • npx biome lint: clean (see Known gaps for format).

  • bin/brakeman --no-pager -q: 0 warnings (9 ignored, unchanged).

  • System tests not run, as in jaysbeekay/sure#332. The fork's CI is authoritative for them.

Issues

Weekly sync per jaysbeekay/sure#118's "Staying in sync while building locally", duty 1. The jaysbeekay/sure#118 sync log can record it once this merges.

Closes #448
Closes #428