Tag rules#90
Draft
MarkIannucci wants to merge 3 commits into
Draft
Conversation
Add an optional account_id to category_rules and name_rules. When set, a rule only fires for transactions on that account; rules with account_id NULL remain global fallbacks. Account-scoped rules take precedence over global rules at the same priority level, achieved via a per-call account filter plus ORDER BY priority DESC, (account_id IS NULL) ASC, id ASC. accountId is threaded through every call site (sync, CSV import, applyCategoriesToAll, rebuildDisplayNames, seedRules, single-shot categorize/applyNameRules). CSV import now also passes amount so amount-filtered rules behave consistently with Plaid sync. - TUI/GUI Rules screens: account picker in both rule forms + scope badge - MCP add_rule/add_name_rule accept account_id; list_rules surfaces scope - deleteAccount removes that account's scoped rules - Tests cover precedence, scoping, CRUD dedupe, deletion, CSV import Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a tag-rule engine that applies tags to transactions by name/regex match or match-all (the per-account default-tag use case = match-all + an account scope). Rules backfill on save and apply to new rows on Plaid sync and CSV import. Removals are permanent: removeTagFromTransaction records a suppression so no rule (existing or created later) re-adds the tag. Manually re-adding the tag clears the suppression — the only undo. Editors show a live match count so a global match-all rule is never a surprise. Full TUI + GUI parity. New core/tag-rules.ts plus tag_rules and tag_rule_suppressions tables. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #84 .
This PR gives us the ability to apply tags using rules. Manual tag removals are remembered and not reapplied.
--- 🤖 Generated with Claude Code
Tag rules with sticky removals
Adds a tag-rule engine that automatically applies tags to transactions, mirroring the existing category/name rule patterns. Rules match by transaction name, regex, or match-all — where match-all + an account scope gives you the "tag everything in this account" default-tag use case.
What it does
Why suppressions
Unlike category stickiness (which can COALESCE over a single manual_category column), tags are many-to-many with no single column to override. A dedicated tag_rule_suppressions table records intentional removals so re-running rules can't undo a user's deliberate choice. All removal paths (TUI, GUI, agent tool) funnel through removeTagFromTransaction, so the guarantee holds at one chokepoint.
Schema
Two new tables (created via CREATE TABLE IF NOT EXISTS):
Notable files
Testing