Page MenuHomePhabricator

New Herald Action To trigger evaluation of another herald rule
Closed, DuplicatePublic

Description

I would like to be able to make a Herald rule where in the actions I could specify something like:

  • Run Herald Rule: [Dropdown of Herald Rules]

or

  • Re-evaluate Herald Rules

It would cause phab to re-evaluate the designated rule conditions (or all rules) to see if it should trigger after all of this rule's actions are performed.

We can already specify a herald rule shouldn't run if another rule passed in the conditions, so a similar dropdown.

Here's my use case: I have tags representing organizational teams, with people members of them.

  • Each team has a rule that executes once that sends an email to the team if a task if tagged with that team.
  • There is a special team called Needs Triage with specific people as members, in case a task does not get created with a team tag. It has a similar email rule.
  • There is a rule that states that if a task has no team tags, and no assignee, then it adds the Needs Triage tag to the task.

My problem: When I create a new task with no tags and no assignee, a herald rule triggers to add the Needs Triage tag to it. However the rule to email members of Needs Triage does not. It will only trigger on the NEXT action on the task, say if I add a comment. This tells me that each rule conditions are on the state before herald rules are applied and can't be impacted by other rules.

My request: Hence this request is to give me the ability to make a bit of a "rule higherarchy" if I know of a rule I was to trigger. Optionally the action could also be "re-evaluate herald rules" so it would trigger again. Some dangers with infinite loops I imagine though which are minimized if you must provide the rule name, though it could just keep track of all execute rules and never execute the same rule twice.

My workaround: Right now I've added an email to the rule that adds the Needs triage tag, but this means that the next comment on the task also emails (when it matches the other rule), resulting in 2 emails for the same task, which is not what I want.

I tried to search and couldn't find this feature requested elsewhere. Hopefully this isn't just me thinking about the problem wrong and just need to re-organize my logic.

Thanks!

Event Timeline

ofbeaton updated the task description. (Show Details)

Sorry, I merged this the wrong way. Nuance is our planned "routing engine" aka Help Desk. We plan to pursue it first and it should be the tool you use to evaluate incoming new objects and where they go.

This comment was removed by chad.

You can already do this with the "Another Herald Rule" condition.

Unfortunately the Another Herald Rule condition does not do what I want, if I understand it correctly.

The first rule adds a tag when there is none. The second rule sends an email if that tag is present. I can't combine them because I want the email fired if someone manually adds that specific tag too.

There's three scenarios:

  • Someone creates a task with no tags. Rule 1 fires and adds the triage tag. Rule 2 runs because the triage tag is there, and sends an email
  • Someone create a task with the triage tag. Rule 2 runs because the triage tag is there, and sends an email
  • Someone unassigns the tags from a task and re-assigns it to triage. Rule 2 runs because the triage tag is there, and sends an email.

The email never fires in the first scenario because each rule from what I can tell take the task state before any rules are applied.

If this feature request is closed because Nuance will handle triaging new tasks in this way, then I'm OK with that.

I was under the impression that Nuance was more only for client facing stuff, so it's not a perfect fit for this scenario.

You can also write your own HeraldAdapter.

Why doesn't this work?

When [any of] these conditions are met:
Tag is present: X
Another herald rule matches: Add tag X to tasks missing assignees/team tags
Take these actions only the first time this rule matches:
Send email to Y

I really hope I'm not missing something here... sincere apologies if I am...

Maybe I am misunderstanding how the "another herald rule matches" works, but I don't think it traverses 2 different actions (say task creation, then a task comment), so it makes the "Take these actions only the first time this rule matches" not work if both rules email. Tomorrow I will test it out to make sure I'm not out to lunch and wasting your time because now I'm worried I am.

Because when the task is created it will match Rule 1 (add the tag), and rule 1 will email me.
When someone does anything to the task, Rule 1 will not match, but Rule 2 (email once when tagged) will match, and email me again.

I will get 2 emails about this task.

Whereas if I can use a Execute Rule 2 (send the email) in the actions of Rule 1 (adding the tag), and only have Rule 2 do the emailing... then the "only match this rule once" will kick in and I will only ever get 1 email for the task.

I'd prefer you ask these questions in Ponder or Conpherence. It's not our expectation to provide this level of support to the community for free.

OK, I'll make my feature request there next time. I didn't ask for support, I made a feature request. I thought those were separate things.

I only listed my scenario to better illustrate why I thought this feature was useful and needed.

As I suspected, thought I had tested, and confirmed again with additional tests this morning, epriestley's "Another herald rule" condition does not solve the problem.

So as far as I'm concerned, being able to chain the evaluation of rules would be a nice feature to have upstream.

For now I have my workaround, even though it does result in an extra duplicate emails.

If Nuance could work on incoming tasks as well as email, it could also solve this problem. I'll make a post there to that effect since it doesn't seem to address this.

epriestley's "Another herald rule" condition does not solve the problem.

This is expected to solve the problem, so if it does not you can file a bug report with complete reproduction steps and we'll take a look at it.

In particular, this failure mode should not be possible:

Because when the task is created it will match Rule 1 (add the tag), and rule 1 will email me.
When someone does anything to the task, Rule 1 will not match, but Rule 2 (email once when tagged) will match, and email me again.
I will get 2 emails about this task.

Because I've suggested that you define rule 2 as an "when ANY of these conditions match" rule instead of a "when ALL of these conditions match" rule, it should be impossible for rule 1 to match without rule 2 also matching. If this can happen, it is a bug, and we'll fix it if you provide reproduction instructions.

(And when multiple rules say "send email" in response to the same action, we don't send 2 emails).

From your followup, it isn't clear if this is actually the failure mode you observed or not.

Thank you very much for your reply @epriestley, and I see what you were trying to say now, I wasn't understanding you before. You were right, I can indeed use your solution (with some modifications), I had not noticed the any of change compared to my own rules.

I had a Assignee does not exist in both rules which meant I could not use any of, however upon careful consideration I can remove it from the send email rule since that would be a very edge case scenario (has needs triage manually entered, is assigned). At that point your solution works.

It also occurs to me that if I needed multiple and conditions I could make a rule that did nothing but just matched those conditions, then used it using a Another herald rule matches to use any of.

This definitely wasn't meant to be a support request but a feature request, but I'll apologise that I hadn't thought of this way of structuring my code, or seen your point when you were nice enough to point it out.

Do you think it is worth outlining this solution in the documentation? Maybe everyone else doesn't need it spelled out, or this is too niche a scenario. I'm not sure.

It also occurs to me that if I needed multiple and conditions I could make a rule that did nothing but just matched those conditions,

Yeah, this is the primary purpose of the "Do Nothing" action.

I'll add a note about these patterns to T8644.