Skip to content

feat(seer): Curate autofix issue labels - #124834

Closed
Mihir-Mavalankar wants to merge 5 commits into
masterfrom
feat/seer-autofix-negative-curation
Closed

Mihir-Mavalankar wants to merge 5 commits into
masterfrom
feat/seer-autofix-negative-curation

Conversation

@Mihir-Mavalankar

Copy link
Copy Markdown
Contributor
  • Sample low-scoring issues and control cohorts after Night Shift, then use an Opus judge to record blinded, event-matched fixability reviews with a per-organization run cap to limit cost.

Sample low-scoring issues and control cohorts after Night Shift, then use an Opus judge to record blinded, event-matched fixability reviews with a per-organization cost cap.
@Mihir-Mavalankar Mihir-Mavalankar self-assigned this Sep 17, 2026
@Mihir-Mavalankar
Mihir-Mavalankar requested review from a team as code owners September 17, 2026 21:13
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 17, 2026

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread src/sentry/tasks/seer/autofix_issue_data.py
Comment thread src/sentry/tasks/seer/autofix_issue_data.py
@Mihir-Mavalankar
Mihir-Mavalankar marked this pull request as draft September 17, 2026 21:31
Comment thread src/sentry/tasks/seer/autofix_issue_data.py
@Mihir-Mavalankar
Mihir-Mavalankar marked this pull request as ready for review September 17, 2026 21:42

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread src/sentry/tasks/seer/night_shift/cron.py Outdated
namespace=seer_tasks,
processing_deadline_duration=5 * 60,
)
def schedule_judging_for_org(organization_id: int) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this could schedule overlapping jobs that race against each other since jobs get sharded into multiple runs. It might be best to limit the judge to the issues scoped in the delivery result, rather than all unscored issues for the org.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The bugbot pointed that out here: #124834 (comment)
It's now in _complete_run which should run once per org right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed the approach a bit to launch this task after all shards are done to address the bugbots comment above too. Lmk what you think

)
)
)
bottom = list(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: is splitting it out like this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Simplified it

Comment on lines +161 to +164
return

run_extras["autofix_issue_data_judging_scheduled"] = True
locked_run.update(extras=run_extras)

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.

Bug: A transient task dispatch failure will permanently prevent judging because the autofix_issue_data_judging_scheduled state flag is not reverted on error.
Severity: MEDIUM

Suggested Fix

To ensure atomicity, move the task dispatch call schedule_judging_for_org.apply_async(...) inside the transaction.atomic block. This will ensure that if the task dispatch fails, the entire database transaction, including the update to the run_extras flag, is rolled back.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/seer/night_shift/delivery.py#L161-L164

Potential issue: In `_schedule_judging_after_delivery`, the state flag
`autofix_issue_data_judging_scheduled` is set to `True` and committed to the database
before the `schedule_judging_for_org` task is dispatched. If the task dispatch fails due
to a transient issue, such as broker unavailability, the exception is caught and logged,
but the state flag is not reverted. A check at the beginning of the function prevents it
from running again if this flag is set, meaning a temporary dispatch failure will
permanently prevent the judging task from being scheduled for that run.

Did we get this right? 👍 / 👎 to inform future reviews.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 982224b. Configure here.

or run_extras.get("autofix_issue_data_judging_scheduled")
or completed_deliveries != locked_run.executions.count()
):
return

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.

Missing shard delivery blocks judging

Medium Severity

Judging is dispatched only when every execution row has autofix_issue_data_delivery_completed. A shard that never callbacks, or a success path that fails inside _process_verdicts before _schedule_judging_after_delivery, leaves the count short forever, so captured issues from the other shards are never reviewed.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 982224b. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is acceptable if it happens rarely.

@Mihir-Mavalankar

Copy link
Copy Markdown
Contributor Author

Closing this PR for different approach

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