Skip to content

Conversation

@trevor-e
Copy link
Member

@trevor-e trevor-e commented Feb 9, 2026

Summary

  • Reduces GitHub status check API calls from ~2 x num_apps to ~2 per commit for multi-app customers
  • Uses a Redis lock + skip logic to deduplicate: one IN_PROGRESS when the first app starts, one terminal check when all apps finish
  • Safety-first: on lock timeout, read error, or any unexpected state, posts anyway (extra check is mostly harmless, stuck check is not)
  • Rerun endpoint bypasses all skip logic
  • Webhook approvals (FAILURE→SUCCESS) post correctly since status changed

Key changes

  • _should_skip_status_check: pure function deciding skip/post based on sibling extras
  • _write_posted_status_claim / _clear_posted_status_claim: claim management in extras
  • Redis lock gate in create_preprod_status_check_task with two-phase approach
  • _update_posted_status_check now persists posted_status on success

Test plan

  • 9 new tests covering multi-app dedup, skip-while-processing, failure+processing, terminal post, rerun bypass, webhook approval, single-app 2-post, API failure claim cleanup
  • All 37 tests pass (28 existing + 9 new)

Without rules configured, both calls compute NEUTRAL status, so the
skip logic deduplicates the second call. Configure rules so the first
call posts IN_PROGRESS and the second posts SUCCESS (different statuses).
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 9, 2026
).values_list("id", "extras")
)
if _should_skip_status_check(
all_artifacts, extras_by_artifact_id, size_metrics_map, status
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm confused why we have all_artifacts already but still need to do another query for extras_by_artifact_id

return False


def _write_posted_status_claim(preprod_artifact: PreprodArtifact, posted_status: str) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

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

Don't we already have another method that updates the posted_status_checks field? Shouldn't that be consolidated together? Otherwise it's a bit confusing we have multiple ways to update that.

artifact.save(update_fields=["extras"])


def _clear_posted_status_claim(preprod_artifact: PreprodArtifact) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

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

It might be fine to keep this duplication but perhaps _clear_posted_status_claim and _write_posted_status_claim can be combined?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think some of the message formatting needs to be updated to work with this properly. For example, now that we will no longer render separate in-progress/success statuses per app, we should probably have a single generic "Your apps are being analyzed" type of messaging.

Copy link
Contributor

@cursor cursor bot left a comment

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 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

include_approve_action=bool(triggered_rules),
)
except Exception as e:
_clear_posted_status_claim(preprod_artifact)
Copy link
Contributor

Choose a reason for hiding this comment

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

Claim cleared unconditionally regardless of post policy

Low Severity

_clear_posted_status_claim is called unconditionally on API failure, but _write_posted_status_claim is only called inside the TRY_TO_DEDUPLICATE block. When post_policy is ALWAYS_POST (rerun endpoint), no claim was written, yet the clear still runs — removing a valid posted_status set by a previous successful run. This performs an unnecessary DB transaction and briefly leaves extras in an inconsistent state between the clear and the subsequent _update_posted_status_check call, during which concurrent sibling tasks could read stale dedup state.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

1 participant