Skip to content

fix(workflow_engine): Apply configured action frequency - #131093

Open
shashjar wants to merge 15 commits into
masterfrom
shashjar/feat/iswf-3705-inbox-frequency
Open

shashjar wants to merge 15 commits into
masterfrom
shashjar/feat/iswf-3705-inbox-frequency

Conversation

@shashjar

@shashjar shashjar commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Refs https://linear.app/getsentry/issue/ISWF-3705/support-group-less-action-invocation-and-inbox-frequency-semantics.

Apply each workflow’s configured repeat interval to each eligible workflow/action pair. An explicit zero or omitted frequency skips per-group status reads and writes for all workflow types, including Inbox, alert, and Seer workflows. This prevents an insert conflict on the first status row from suppressing one of two concurrent evaluations when no interval is configured. If a workflow later enables a positive interval, its throttle uses any status left over from an earlier positive interval.

Positive intervals retain existing per-group suppression and insert-conflict handling. An eligible action without a group skips per-group state. Handler validation precedes throttling, and equivalent actions still dispatch once per evaluation.

https://app.notion.com/p/sentry/Investigation-Events-Workflow-Engine-40c8b10e4b5d80d18c4ed6c802d55d64

@linear-code

linear-code Bot commented Nov 13, 2026

Copy link
Copy Markdown

ISWF-3705

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 13, 2026
@shashjar
shashjar added this pull request to stack #131096 November 13, 2026 18:30
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-inbox-frequency branch from 87e8566 to b255042 Compare November 13, 2026 18:39
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-inbox-frequency branch 2 times, most recently from 4a78323 to d5fc207 Compare November 19, 2026 23:59
@sentry

sentry Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 1164 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-inbox-frequency branch from d5fc207 to 8c2ff58 Compare November 20, 2026 00:13
@shashjar
shashjar removed this pull request from stack #131096 November 20, 2026 00:15
@shashjar
shashjar added this pull request to stack #131948 November 20, 2026 00:15
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-inbox-frequency branch 8 times, most recently from 73db373 to e48baa7 Compare November 20, 2026 23:07
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

No findings on the latest commit.

@shashjar
shashjar requested review from a team November 21, 2026 17:48
@shashjar
shashjar marked this pull request as ready for review November 21, 2026 17:48
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-inbox-frequency branch from 09c4af6 to 3355be7 Compare November 23, 2026 16:44
@shashjar
shashjar requested a review from a team November 23, 2026 17:39
@shashjar
shashjar requested review from a team as code owners November 30, 2026 18:31
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-inbox-frequency branch from d7bbafc to d074324 Compare November 30, 2026 18:37
@shashjar
shashjar requested a review from saponifi3d November 30, 2026 19:57

@saponifi3d saponifi3d left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could probably reduce the number of queries / lookups dicts being built between get_eligible_action_workflows and filter_recently_fired_workflow_actions.

as a follow-up we'll probably want to introduce some caching layers here as well, so we don't have to do these queries for each time we want to trigger an action.

Comment on lines 370 to 372
action_to_workflows_ids = get_eligible_action_workflows(filtered_action_groups, event_data)

actions_queryset = Action.objects.filter(id__in=list(action_to_workflows_ids.keys()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is querying into the actions table twice, once in get_eligible_action_workflows and then again on the Action.objects.filter -- is that needed? could we do this with a single query?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, good catch. changed this to be a single query in get_eligible_actions and then reused

Comment on lines +330 to +336
active_actions = Action.objects.filter(
id__in={action_id for action_id, _, _ in associations}, status=ObjectStatus.ACTIVE
)
# Inactive actions count towards frequency and history, but may have retired handler types.
unsupported_action_ids = {action.id for action in active_actions} - {
action.id for action in get_supported_actions(active_actions, event_data)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 could get_supported_actions return the supported / unsupported actions in a tuple or something for us? that way it could all be handled within that helper (in the future, it'd be easier to add any caching etc that might be needed)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i ended up making a separate _action_supports_event helper which i think adding caching to later should be easy

"condition_group__workflowdataconditiongroup__workflow_id",
"condition_group__workflowdataconditiongroup__workflow__config",
)
active_actions = Action.objects.filter(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a cache for these actions? it is pretty unlikely to change the configuration on the workflow would change (relative to the number of evaluations), and when it does we can bust the cache and have it be a read-through.

there's already a cache directory in workflow engine that should make that a lot easier to implement (probably should be a separate PR after this one though).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WorkflowActionGroupStatus objects.
"""

action_to_workflows_ids = get_eligible_action_workflows(filtered_action_groups, event_data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe instead of get_eligible_action_workflows, it could be get_eligible_actions and then have this return the actions (since it has to query for them already)? The name starting with get_ gives me the initial expectation that there will be an Action as a result of this method.

it also looks like this is re-building the same dict in the result here for action_to_workflow_id.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. made get_eligible_actions the entrypoint (replacing filter_recently_fired_workflow_actions) returning the loaded actions + their workflow attributions

@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
scraps Ignored Ignored Preview Dec 3, 2026 3:48am UTC

Request Review

Keep alert throttling per workflow/action association and record history only for eligible workflows.

Refs ISWF-3705
Exercise group-less eligibility with an unrestricted handler instead of setting the removed capability flag.

Refs ISWF-3705
Keep the frequency and history contracts concise and remove unused fixture state.

Refs ISWF-3705
Reject unsupported actions before writing group frequency state so a later supported event can still fire.

Refs ISWF-3705
Reuse the alert scenarios for Seer suppression and exclusion from group-less evaluations.

Refs ISWF-3705
Require callers to provide evaluated workflow eligibility while retaining organization-scoped history filtering.

Refs ISWF-3705
Describe event validation before frequency and history, and Inbox-only eligibility without a group.

Refs ISWF-3705
Skip per-group status for zero and omitted intervals, validate actions before throttling, and select group-less activity workflows by source. Move shared-action fire-history attribution into its independent fix.
Activity processing requires a group before workflow selection. Keep the
group-less frequency rule in action eligibility and document when it uses group status.

Refs ISWF-3705
…ions

Keep inactive actions eligible for history and throttling while skipping their handlers.
Validate active actions before throttling and again at dispatch if their status has changed.
Treat a stored null frequency as zero and cover eligibility with frequency-based fixtures.

Refs ISWF-3705
Read action type and status alongside workflow associations, then load eligible actions once. Deduplicate the loaded actions in memory and keep the last action for each key.

Refs ISWF-3705
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-inbox-frequency branch from ccdf440 to 89b03ef Compare December 3, 2026 03:47
@shashjar
shashjar removed request for a team December 3, 2026 03:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants