Add rule actions to set or append transaction notes #4346
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 642 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.387
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4346"
general
weight: 0.35
jjmata
Summary
Before: rules can match on transaction notes but cannot write them. Notes such as "Check receipt" or "Reimbursable" have to be added by hand on every transaction.
After: two new transaction rule actions.
Release notes: Rules can now set transaction notes or add a line to them.
How
Rule::ActionExecutor::SetTransactionNotesandAppendTransactionNotesaretype "text", like Set transaction name. Both writeentries.notesthroughentry.enrich_attribute(:notes, ..., source: "rule").ignore_attribute_locks, the same as the name action.- New executor hook
blocking_attributes(default:claimed_attributes) names the claims that keep an action away from a transaction.Rule#applynow excludes byblocking_attributes; every existing action keeps its behavior because the default is unchanged.- Set claims
notesand is blocked bynotesandappended_notes.- Append claims
appended_notesand is blocked only bynotes.- Result: several append rules each add their line, a set rule above wins over appends below, and an appended line is never wiped by a set rule further down.
conflicting_note_actions): replace and append in the same rule would rewrite the notes on every run. Two separate rules work as described above.t()(en, de; other locales fall back to en). Theconflicting_note_actionserror is translated in every locale that hasduplicate_actions.get_rule_optionsdescribes the expected value of both actions for the assistant.Scope and permissions
Only
entries.noteschanges; balances, reports, budgets and syncs are not affected. Each change writes adata_enrichmentsrow with sourcerule, like the other rule actions. Action types are free strings, so rule export/import and the read-only rules API carry the new types without changes. No migrations.Rules stay family-wide and non-guest only, the same as the existing name, category and merchant actions; this PR does not change who may create rules.
Coordination with other rule PRs
ACTION_EXECUTOR_CLASSES.test/models/rule/action_test.rb, as this PR does. Whichever lands second keeps both; no code overlap.Screenshots (demo data)
| Before | After |
|---|---|
| !before | !after |
A transaction after an append rule ran (existing note "Paid by card" plus the appended line):
!transaction notes
Testing
test/models/rule/action_test.rb: set, append, duplicate check, whole-line matching, multi-line values, blank values, locks and lock override.test/models/rule/runner_test.rb: a blank set or append action above leaves the notes to the rule below.test/models/rule/runner_test.rb: set above beats append, append above keeps set below away, two appends add up and stay stable across repeated runs.test/models/rule_test.rb: a rule with both note actions is rejected.test/models/assistant/function/get_rule_options_test.rb: value description for the append action.bin/rails teston current main: 12,448 runs, 0 failures, 0 errors.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
- Added rule actions to replace transaction notes or append new note lines.
- Appended notes ignore blank values, avoid duplicates, support multiline text, and respect locked notes unless explicitly overridden.
- Rules can no longer combine note replacement and note-appending actions, preventing conflicting behavior.
- Added translated labels and validation messages for the new note actions across supported languages.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->