Skip to content

ref(autofix): Gate manual PR iteration behind its own feature flag - #121180

Merged
alexsohn1126 merged 3 commits into
masterfrom
alexsohn/cw-1778/disable-manual-pr-iteration-by-another-feature-flag-backend
Aug 4, 2026
Merged

ref(autofix): Gate manual PR iteration behind its own feature flag#121180
alexsohn1126 merged 3 commits into
masterfrom
alexsohn/cw-1778/disable-manual-pr-iteration-by-another-feature-flag-backend

Conversation

@alexsohn1126

@alexsohn1126 alexsohn1126 commented Aug 4, 2026

Copy link
Copy Markdown
Member

Backend half of CW-1778. Frontend follows in a separate PR (static/ and src/ aren't atomically deployed); this lands first.

Why

organizations:autofix-pr-iteration currently gates both manual and automated CI PR iteration. That means we can't roll out automated CI iteration without also exposing the manual flow. This adds organizations:autofix-pr-iteration-manual (api_expose=True, the frontend needs it) and moves the human-triggered entry points onto it, leaving automated CI iteration on the existing flag.

Moved to -manual

Site Gates
group_ai_autofix.py:358 the pr_iteration POST gate — only reachable from the drawer feedback form; automated CI iteration enters via the check_suite listener, not this endpoint
pr_iteration/mention.py:88 @sentry <feedback> PR comment trigger
pr_iteration/listeners/review.py:145 PR review / inline review comment trigger
autofix_agent.py:887 the "Comment @sentry <feedback>…" PR description footer
on_completion_hook.py:252 👀->🎉 reaction swap on the triggering comment

Accepts either flag

Two sites sit on the shared path and would have broken automated CI iteration if moved outright — the check_suite listener reaches both via trigger_consume_pr_iteration_feedback -> trigger_autofix_agent(step=PR_ITERATION):

  • autofix_agent.py:416pr_iteration_enabled, which raises PrIterationNotEnabledException for any PR_ITERATION step
  • agent/client.py:359 — the enable_pr_context_tools permission check, set from is_iteration_step for both flows

New response field

pr_iteration_enabled keeps its existing meaning (automated CI iteration). Manual state is reported by a new additive field, manual_pr_iteration_enabled, rather than by redefining the old one — an unread field today is one a future reader would misinterpret. test_get_reports_iteration_flags_independently pins all four flag combinations.

Unchanged

The automated CI entry point (pr_iteration/listeners/check_suite.py) has no autofix-pr-iteration check of its own; its sub-features already use separate flags (-review-request, -cap-assign).

Rollout

Orgs currently on autofix-pr-iteration keep automated CI iteration and lose manual iteration until autofix-pr-iteration-manual is enabled for them — enable the new flag for the existing org set before/with this deploy to keep behavior identical. Flagpole YAML lives in sentry-options-automator.

Tests

Manual-gate tests moved to the new flag. Three things worth calling out, each verified by mutation testing rather than assumed — in every case I widened the gate back to the coupled behavior and confirmed the test fails:

  • The feature_disabled tests were vacuous. They relied on both flags defaulting off, so they passed even with a manual gate mutated to also accept autofix-pr-iteration. Each now turns the automated flag on while manual is off, so the assertion is "automated CI iteration does not grant manual iteration."
  • The flag swaps in the test_skips_* tests are load-bearing, not churn. Left on the old flag, the feature check short-circuits ahead of the condition each test targets: test_skips_when_not_iterate_command still passes when fed a valid @sentry fix it body, because the disabled feature is what stops dispatch. Swapping the flag is what keeps those assertions meaningful.
  • Both response fields report independently, so the two flows can't be conflated by a future edit.

New coverage:

  • test_pr_iteration_enabled_by_either_flag — neither flag raises PrIterationNotEnabledException; each flag alone enables the step. This exception had no coverage before.
  • test_client_init_succeeds_when_manual_pr_ctx_tools_flag_enabled — PR context tools under the manual flag; the existing old-flag test now pins the automated path.
  • test_get_reports_iteration_flags_independently — all four flag combinations for the two response fields.

274 passed across the touched files. 6 unrelated failures in test_issue_search.py / test_coding_agent_handoffs.py reproduce identically on a clean master tree (verified via git stash).

refs CW-1778

@linear-code

linear-code Bot commented Aug 4, 2026

Copy link
Copy Markdown

CW-1778

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 4, 2026
@alexsohn1126
alexsohn1126 marked this pull request as ready for review August 4, 2026 16:24
@alexsohn1126
alexsohn1126 requested a review from a team as a code owner August 4, 2026 16:24
`organizations:autofix-pr-iteration` currently gates both manual and
automated CI PR iteration, so the automated flow can't ship without also
exposing the manual one. Add `organizations:autofix-pr-iteration-manual`
and move the human-triggered entry points onto it:

- the `pr_iteration` POST case and the `pr_iteration_enabled` field the
  drawer reads
- `@sentry <feedback>` PR comments and PR review triggers
- the "Comment `@sentry ...`" PR description footer
- the completion 👀->🎉 reaction swap

`trigger_autofix_agent` and the `enable_pr_context_tools` check are shared
by both flows — automated CI iteration reaches them via the check_suite
listener — so those accept either flag rather than moving.

The automated CI entry point keeps using `autofix-pr-iteration`; its
sub-features already have their own flags.

Frontend follows in a separate PR.
…ated flag

The `feature_disabled` tests relied on both flags defaulting off, so they
passed even with the manual gate mutated to also accept
`autofix-pr-iteration` — i.e. they never verified the decoupling this
change is for. Turn the automated flag *on* in each, so the assertion is
"automated CI iteration does not grant manual iteration".

Verified by mutation: with each manual gate widened to accept either flag,
all five of these tests now fail.
The previous commit repointed the `pr_iteration_enabled` response field at
the manual flag, silently redefining what an existing API field means for
its consumers. Restore its original meaning and add
`manual_pr_iteration_enabled` alongside it, so each flow reports its own
state.

The POST gate for `step="pr_iteration"` stays on the manual flag: it's only
reachable from the drawer feedback form, and automated CI iteration enters
via the check_suite listener rather than this endpoint.

`test_get_reports_iteration_flags_independently` pins all four flag
combinations; verified by mutation that it fails if the two fields are
sourced from the same flag.
@alexsohn1126
alexsohn1126 force-pushed the alexsohn/cw-1778/disable-manual-pr-iteration-by-another-feature-flag-backend branch from daf360a to 5f0ac58 Compare August 4, 2026 17:47
@alexsohn1126
alexsohn1126 merged commit 95d6534 into master Aug 4, 2026
86 checks passed
@alexsohn1126
alexsohn1126 deleted the alexsohn/cw-1778/disable-manual-pr-iteration-by-another-feature-flag-backend branch August 4, 2026 20:22
alexsohn1126 added a commit that referenced this pull request Aug 4, 2026
…#121189)

Frontend half of CW-1778. Depends on #121180 (backend) for the new flag
registration — land that first.

`autofix-pr-iteration` gates both manual and automated CI PR iteration,
so automated CI iteration can't ship without also exposing the manual
UI. The backend PR added `organizations:autofix-pr-iteration-manual`;
this moves the user-driven affordances onto it.

current ui when manual feature flag is of -- you can still see the
automatic iterations in the form of feedback, but we removed the form to
trigger the iteration with a manual feedback.

<img width="824" height="632" alt="image"
src="https://github.com/user-attachments/assets/f76f7b83-1c48-4584-ac33-a10549135be1"
/>

with the manual flag -- show manual feedback form again:

<img width="823" height="722" alt="image"
src="https://github.com/user-attachments/assets/16b13200-d6c2-4342-aad7-0b304f44bc95"
/>


Fixes
[CW-1778](https://linear.app/getsentry/issue/CW-1778/disable-manual-pr-iteration-by-another-feature-flag)
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