Add the overlaps section to Rule health
Closes jaysbeekay/sure#702
Upstream issue: we-promise/sure#5175
Upstream PR: we-promise/sure#5527 (same branch, same commit), in native stack we-promise/sure#5529
Stacked on jaysbeekay/sure#796 (up/rule-health); the diff below is this branch's own commits. jaysbeekay/sure#797 (up/rule-similar-warning) now stacks on this branch, since its save-time check reuses the text comparison added here. Split out of #796 to keep that change near the ~300-line guide (owner decision, 2026-11-17); #796 is now "Part of" the issue and this slice closes it.
Summary
Adds the Overlaps section to the Rule health page: active rules below another that sets the same field on transactions both match ("1 of its 2 matches are also matched by the rule above"), or whose conditions name the same or contained text (a merchant condition read as the merchant's name) with otherwise the same conditions, so uber AND amount > 100 and uber AND amount < 10 are not listed. Pairs already listed as duplicates or conflicts, and shadowed rules, are left out.
What changed
Rule::Health#overlaps, withsame_text?,texts,conditions_besides_textandmerchant_names, exactly as reviewed on #796 at 88d98be0b (commit "Add the overlaps section to Rule health" is the revert of its removal there).- Review fix (Gatekeeper full review 6946839460, finding 4):
same_text?folded every condition's text, so= Uberand= uberwere listed as the same text although=matches case and the two rules match disjoint transactions. Text is now folded only when one side runs as ILIKE (like,starts_with,ends_with), the same rulecondition_valueuses. rules/_health_report.html.erboverlaps section and itsrules.health.overlaps.*strings.
Size: 97 non-test lines (health.rb 83).
Deliberately left out
- Finding 5 (
merchant_namesreadsMerchantunscoped): declined. The ids come from the family's own rule conditions, the name is only compared as text and never rendered, andfamily.merchantswould drop the provider merchants a merchant condition legitimately names (TransactionMerchant#optionslistsavailable_merchants_for). Scoping throughavailable_merchantsadds a pluck of every transaction's merchant id per report for no exposure. - The shared count reads matches before any rule runs, like the rest of the report; it is advisory, and #796 now holds back the shadowed and match-nothing verdicts where a rule above changes what a rule reads.
Blast radius: who else hits this line, and what do they pass?
same_text?andtextsare read byoverlapshere and byRule::Health#similar_toin #797, which passes the form's unsaved rule; both get the same case rule.condition_value(duplicates, conflicts) is unchanged here.
Tests
test/models/rule/health_test.rb: the 8 overlap tests moved back from #796, plus 1 new; rules_controller_test.rb: the report test asserts the overlaps section again.
| Test | Kind |
|---|---|
| shared transactions on the same field: overlap, 1 of 2 | positive |
| shared transactions, different fields: no overlap | negative |
| "contains uber" vs "= UBER EATS": overlap with 0 shared | positive |
= "Uber" vs = "uber": not the same text (new; failed before the fix: overlap listed with same_text=true) | negative |
| contained text with contradicting amount conditions: no overlap | negative |
| contained text inside an OR group: still the same text | positive |
| merchant condition read by name: overlap; merchant renamed: none | delta |
| contained text, different fields: no overlap | negative |
| same conditions, same value, plus another action: overlap | positive |
| controller: report renders the conflicts, shadowed and overlaps sections | controller |
Mutations (container copy only)
| Mutation | Caught by |
|---|---|
| fold text for every operator | = "Uber" vs = "uber" |
| never fold text | merchant condition read by name |
| overlaps ignore the shared field, merchant compared by id, skip every same-conditions pair | carried from #796's table at 88d98be0b, code unchanged |
Validation
health_test.rb,rules_controller_test.rb,runner_test.rb,runner/claims_test.rbat 102e4ff29: 129 runs, 0 failures, 0 errors. Full suite: CI on this branch.rubocopanderb_linton the changed files: no offenses.- Checked against upstream
AGENTS.md:t()for every string, DS::Section as in #796, no new dependencies.
Refresh (2026-11-22)
- Merged
up/rule-health(with current upstreammain) in; no conflicts. New commit 2d521e66d: the shared line pluralises on the shared count ("1 of its 2 matches is…", "2 of its 3 matches are…"); new controller test failed before on1 of its 2 matches is. - Full
bin/rails testat 2d521e66d: 18187 runs, 0 failures, 8 errors (environmentalReleaseNotesWorkflowTest, nonode).
Screenshots
Before (up/rule-health, a53e59371): Duplicates and Shadowed only. After (2d521e66d): the Overlaps section, light, dark and mobile.
| Before | After | |
|---|---|---|
| Light | ![]() | ![]() |
| Dark | ![]() | ![]() |
| Mobile | ![]() | ![]() |





