Repository navigation
fix(automation): fire tag_added only when the tag is actually added (#554) - #556
Conversation
…aca-AI#554) The tag_added trigger matched whenever the configured tag was present on the task, and every update to the tags field produced a tag_added candidate. Any later, unrelated tag edit (or a removal) therefore re-fired automations whose tag had been added long before, which in multi-stage review pipelines made tasks bounce back to earlier stages and started duplicate agent runs. The consumer now derives the tags an update added from the change's old and new values and passes them to trigger matching: a configured tag must be among them (and still present on the task), and an unconfigured tag_added trigger needs at least one addition. Removal-only edits no longer produce a tag_added candidate. Fixes Paca-AI#554
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
tag_addedfires only on an actual addition —handlenow computes the tags an update introduced via the newaddedTags(change)helper (new-minus-old over the decodedFieldChange.Old/.New), only appendsTriggerTagAddedwhen the set is non-empty, and threadsaddedthroughprocessEventintotriggerMatches.triggerMatchesconditions tightened — a configured tag matches only when it is inaddedand still on the task; an unconfigured ("any tag") trigger requires at least one addition, so a removal-only edit no longer matches.- Tests — regression case for an unrelated tag added while the configured tag is already present, the removal-only/any-tag case, and an
addedTagsJSON round-trip; existingtriggerMatchescallers updated for the new parameter.
I verified the surrounding contracts: FieldChange{Old,New any} decodes JSON arrays to []any (which addedTags handles, including null old and empty new); the only two producers of a tags change (task_handler.go:1307, task_autofill_consumer.go:686) both populate Old/New, so no path silently stops firing; tags are persisted verbatim (task_service.go:668), so added and task.Tags cannot diverge. go vet ./internal/worker/ is clean and the targeted tests pass, and the existing e2e happy path (add urgent to an empty task) still matches.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
pikann
left a comment
There was a problem hiding this comment.
LGTM! Please fix the failing lint check before merging.
Thank you for your contribution! 🚀
…es-only-on-addition
|
Thanks for the review! The Lint failure wasn't from this change: it was |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The only commit since the prior pullfrog review is 2cc35a44, a merge of upstream/master into the branch. It does not touch this PR's own files, and the tag_added fix is byte-identical to the version reviewed at e92af8bb.
- Merged
upstream/master— brings in the notification-title work (#553) plus88bca4fa, which fixes the pre-existingnoctxlint violation ininternal/platform/plugin/email_test.go(net.Listen→(*net.ListenConfig).Listen) that was unrelated to this PR but had turned theapi-pr-ciLint job red. The Lint run ate92af8bbreported exactly one issue — thatemail_test.goline — so the PR-authoredautomation_consumer.gocode is lint-clean.
No inline comments: the delta carries no behavioral change authored by this PR.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Summary
Fixes #554. The
tag_addedautomation trigger matched whenever the configured tag was present on the task, and every update to thetagsfield produced atag_addedcandidate. Any later, unrelated tag edit (or a removal) therefore re-fired automations whose tag had been added long before. In multi-stage review pipelines, where each stage's sign-off is a tag, tasks bounced back to earlier stages and duplicate agent runs started.The automation consumer now derives the tags an update added from the change's
old/newvalues and passes them to trigger matching:tag_addedtrigger ("any tag") needs at least one addition;tag_addedcandidate at all.This matches what the trigger is documented to do ("a tag is added";
{tag?}, omit = any tag), so no docs change was needed.Type of Change
Checklist
services/api/internal/worker/automation_consumer.goand its tests.addedTagsacross a JSON round trip; the existingtriggerMatchestests were updated for the new parameter.go vetclean;go test ./...inservices/apipasses.