Skip to content

Group-scoped rules and drift detection

Group-scoped rules and drift detection

Status: Delivered
CAS: CAS-515
Delivered: 2026-04-25
PRs: #172, #173, #174, #175, #176, #183

What’s new

Casaconomy’s automatic categorisation rules can now be scoped to a specific Group. When you create or edit a trip-style Group with start and end dates, the app automatically generates a date-window rule that routes matching transactions into that Group without any manual setup. If you later edit the trip dates, a drift-detection system notices the mismatch and surfaces a prompt to accept or discard the updated rule — so your rules stay aligned with your groups without ongoing maintenance.

How to use it

Group-scoped rule browser:

  1. Open a Group’s detail view and navigate to the Rules tab to see rules scoped to that group.
  2. Group-scoped rules only match transactions when the active group context matches; generic rules continue to apply everywhere.

Auto-generated rules on Group create/edit:

  • When you create or edit a Group and set event dates (start/end), Casaconomy automatically generates a date-window rule for that group.
  • No visit to the Rules page is required; the rule appears there for reference.
  • If you edit the rule manually, the system marks it user_edited and stops auto-updating it.

Drift detection:

  • When a Group’s dates change and an auto-generated rule no longer matches them, a drift notification appears in two places:
    • A strip on the main Dashboard
    • A banner inside the Group detail view
  • Click Update rule to accept the new dates, or Keep current to lock your manual override and suppress further drift warnings for this rule.

What changed under the hood

  • Schema migration adds group_id, is_auto_generated, and user_edited columns to the rules table; rules without a group scope are unaffected.
  • New AssignToGroup rule action and evaluator route matching transactions into a specified group at categorisation time.
  • Auto-rule generation runs on create_group and edit_group: when event dates are present, a date-window rule is created or updated automatically (skipped if the rule has been user-edited).
  • Drift detection: new scan_rule_drift and resolve_rule_drift Tauri commands check for mismatches between a group’s dates and its auto-rules, returning structured RuleDrift payloads consumed by the notification UI.
  • New get_rules_by_group Tauri command allows the group rule browser to display only the rules belonging to a given group.
  • New frontend surfaces: group-scoped rule list inside the Group detail view, and drift notification strip on the dashboard and group detail banner with one-click resolution.

Why we built it

Manual categorisation rules are powerful but fragile — the moment a trip changes dates, all the date filters become wrong and transactions start missing their group. Auto- generating rules from group metadata removes the setup busywork, and drift detection closes the loop: rather than silently mis-categorising, the app tells the user something is out of sync and offers a one-click fix. Together these features make Groups genuinely low-maintenance for recurring use cases — annual trips, household budget periods, shared events.

Known limitations / follow-on work

  • Auto-rule generation only triggers for groups with explicit event dates; open-ended groups (e.g., a permanent household group) do not get auto-rules.
  • Drift detection currently covers date-window mismatches only; rule conditions beyond date ranges are not yet checked.
  • The group-scoped rule list does not support inline editing — rules must be edited via the main Rules page.
  • Multi-device rule sync is deferred to a later sync phase.