← Back to Pull requests

Merge upstream/main into main (weekly sync, refreshed 2026-10-20) #464

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 15, 2026 04:59 UTC
Author

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).

| Commit | What |
| --- | --- |
| 1ab736326 | Merge upstream main. 11 conflicted files, resolved as below. |
| 40c4be22c | Upstream'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.

    | Commit | What |
    | --- | --- |
    | 79b29324a | Merge fork main (clean). |
    | 2ea8d2867 | Merge upstream main. 16 conflicted files, resolved as below. |
    | a0f70dc57 | Fork migration renumbered to 20261015090001, plus guarded 20261018090000. |
    | faa3f52c2 | Restores 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:

    | Commit | What |
    | --- | --- |
    | 679c16725 | The merge. Parents 8d4842986 (fork main) and a3bb5d991 (upstream). 91 conflicted files, each listed below. |
    | 9082f803c | Three 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. |
    | 4ac18ac4e | Records 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. |
    | ab3f8a127 | Fork-only migration 20261015090000: carries each family's rule outcome from priority into position, then drops priority. |
    | eafa42835, 948a0175e, 390d47330 | jaysbeekay/sure#448's port, cherry-picked from up/net-contributions-model (f87a751af, 8fc7f6aed, 1fb0df306). |
    | 2da501fe2 | A 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). |
    | 821b548c5 | A fork FinanceKit test still counted the retired ApplyAllRulesJob; the downstream now queues ApplyRulesJob (we-promise/sure#4013). |
    | 9bbcc19ac | The rules rake test (from we-promise/sure#4013) loads only rules.rake, so it no longer flakes on test order (comment 6211978487). |
    | 80ce7dfda | The 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) |
    | --- | --- | --- |
    | Column | rules.priority (20261001090000, seeded by created_at) | rules.position + stop_processing (20261006140000, seeded A-Z by name) |
    | Order | Rule.prioritised: (priority, created_at, id) ascending | Rule.ordered: (position, created_at, id) ascending |
    | Who wins a contested field | the last rule (each overwrites the one before) | the first rule (it claims the field) |
    | Runner | ApplyAllRulesJob(active_only:, ignore_attribute_locks:) | Rule::Runner, ApplyRulesJob after sync, ApplyAllRulesJob from the page |
    | UI | up/down arrows, priority sort | drag 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. The chain wins: reversed, B would miss the renamed rows and lose every action it has on them, not just the category. On rows both match, A's category now wins. The migration prints each such pair ("Rule X now runs before rule Y to keep a chain...").

    Down re-adds priority (with its index) and backfills it from position, reversed, so the top rule runs last again. A chain that up kept in the fork's order comes back reversed, because position does not record which pairs were chains; the migration says so.

    Proof (test/migrations/convert_rule_priority_to_position_migration_test.rb, 10 tests, 30 assertions). 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 --:

    | Mutation | Result |
    | --- | --- |
    | Drop the mirror direction (writes[j] & reads[i]) | test 2 fails |
    | Ignore sub-conditions | test 4 fails |
    | Drop conflict edges | test 3 fails |
    | Tie-break forward (ready.min) | test 6 fails |
    | No report for an unkept conflict | test 7 fails |
    | Tags not counted as a write | test 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)

    | File | Resolution |
    | --- | --- |
    | app/models/rule.rb | Upstream'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.rb | Upstream'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.rb | Upstream'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.rb | Upstream's ApplyRulesJob.perform_later(family) (active rules, locks respected: the same inputs the fork passed). |
    | app/models/financekit/downstream.rb | Same as the syncer. |
    | app/views/rules/index.html.erb | Upstream'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.jbuilder | Upstream's position and stop_processing. |
    | config/locales/views/rules/en.yml | Upstream'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.rb | Upstream's position and stop_processing. |
    | test/controllers/rules_controller_test.rb | Both 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.rb | Upstream's position assertions. |
    | test/models/family/syncer_test.rb | Upstream's. |
    | db/schema.rb | Version 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.rb | Upstream'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.rb | Deleted: 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

    | File | Upstream PR | Resolution |
    | --- | --- | --- |
    | app/models/security/split.rb (add/add), app/models/holding/portfolio_cache.rb, app/models/holding/reverse_calculator.rb | we-promise/sure#3850 | Upstream'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.rb | we-promise/sure#3850 | Upstream's added tests. |
    | app/models/holding/cost_basis_tracker.rb | we-promise/sure#4033 | Upstream's comment. |
    | app/models/balance_sheet/net_worth_velocity.rb, test/models/balance_sheet/net_worth_velocity_test.rb (add/add) | we-promise/sure#4083 | Upstream'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#3557 | Code 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.rb | we-promise/sure#4082 | Composed. 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.rb | we-promise/sure#4082 | Cache key totals_query/v5 (the fork was at v4, upstream at v2): signed income changes what the columns mean. |
    | test/models/investment_statement_test.rb | we-promise/sure#4082 | Upstream'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#4048 | Upstream'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.rb | we-promise/sure#4046, we-promise/sure#4050 | Comment only: upstream's issue reference. |
    | app/models/enable_banking_item/sync_complete_event.rb | we-promise/sure#4044 | Upstream's: the panel is no longer streamed to the family. |
    | test/controllers/accounts_controller_test.rb | we-promise/sure#4046, we-promise/sure#4048 | Upstream'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.rb | we-promise/sure#4046 | Upstream's (passes visible_accounts:; comments). |
    | test/lib/tasks/simplefin_pending_cleanup_test.rb (add/add) | we-promise/sure#3557 | Upstream's; identical to upstream. |
    | test/models/simplefin_item/importer_stale_unmatched_pending_test.rb (add/add) | we-promise/sure#3557 | Kept 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#4013 | Upstream'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.md | upstream f715e06d5, e76057b43, 4b1d282d9 (the fork's jaysbeekay/sure#176 doc, as reviewed upstream) | Upstream's wording. |

    Composed: both sides kept

    | File | Resolution |
    | --- | --- |
    | app/models/account/market_data_importer.rb | Upstream'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.rb | Upstream'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.rb | Kept 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.rb | Kept the fork's taggings, constituents and classification-proposal associations next to upstream's splits. |
    | app/models/plaid_account/processor.rb | Upstream's BalanceError plus the fork's as_of reader (loan rate-change dating). |
    | app/views/layouts/application.html.erb | The fork's portfolio_nav_item plus upstream's assistant item gated on assistant_enabled (we-promise/sure#4147). |
    | app/views/properties/tabs/_overview.html.erb | Both: the fork's UI::Account::CollateralPosition, then upstream's Chimnie valuation source and refresh button (we-promise/sure#4135). |
    | test/controllers/properties_controller_test.rb | Both: the fork's collateral tests and upstream's Chimnie tests. |
    | test/controllers/reports_controller_test.rb | Both: 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.rb | Kept 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.rb | Both: the fork's updated_at stamping test and upstream's three carry-forward tests, plus upstream's private helpers. |
    | test/models/goal_test.rb | Both: the fork's milestone tests and upstream's colourless-ring test (we-promise/sure#4032). |
    | test/models/snaptrade_account/activities_processor_test.rb | Both: the fork's duplicate-ticker test and upstream's option tests (we-promise/sure#3744). |
    | test/models/trade_test.rb | Both 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

    | File | Resolution |
    | --- | --- |
    | 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.rb | Fork'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 --):

    | Mutation | Caught 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 check | the 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 check | the 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

  • 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

    <!-- This is an auto-generated description by cubic. -->
    <a href="https://cubic.dev/pr/jaysbeekay/sure/pull/464?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/jaysbeekay/sure/464?returnTo=https%3A%2F%2Fgithub.com%2Fjaysbeekay%2Fsure%2Fpull%2F464&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. -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: jaysbeekay Review duration: 10238m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)). 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%
    42%
    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 #464"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 29.7% · Safe to merge
    29.7%