Repository navigation
Harden fork CI reconciler state transitions and closure rules - #76956
Conversation
|
Your CI change needs a maintainer. CI for this pull request runs in your fork, and the workflow runs it starts in apache/airflow are approved automatically while they only run the fork CI gate. This pull request changes files that define what CI runs:
Such a change can make project CI run on the project's runners, so its workflow runs in apache/airflow wait for a maintainer to review the change and approve them. CI in your fork is not affected, and its result stays visible on this pull request. Pull requests from contributors run their CI in the contributor's own fork. GitHub Actions is free and has no minute limit on public forks, while the CI capacity of the Apache Software Foundation is shared by every ASF project and is finite. This comment was posted automatically by the fork CI monitor from templates drafted with an AI-assisted tool, so it may contain mistakes. An Apache Airflow maintainer, a real person, will review the pull request once its fork CI is green. Why the first pass is automated. |
|
Closing this pull request because it changes the fork CI gate: it changes The gate decides whether a pull request runs its CI in apache/airflow or in the contributor's fork. It is made of the If the change is wanted, a maintainer can reopen the pull request and add the This comment was posted automatically by the fork CI monitor from templates drafted with an AI-assisted tool, so it may contain mistakes. An Apache Airflow maintainer, a real person, will review the pull request once its fork CI is green. Why the first pass is automated. |
|
Project CI in use. A maintainer added the This comment was posted automatically by the fork CI monitor from templates drafted with an AI-assisted tool, so it may contain mistakes. An Apache Airflow maintainer, a real person, will review the pull request once its fork CI is green. Why the first pass is automated. |
|
Pushed commit
Since GitHub freezes the pull request commit view while closed, the commit is live on the branch here: |
|
Updated Docs Since the bot closed the PR, GitHub freezes the commits view until it gets reopened. The latest changes are live on the branch here: meel-ayush@ecb730f Could a maintainer please reopen this PR for review? |
ecb730f to
e366753
Compare
potiuk
left a comment
There was a problem hiding this comment.
Counting review comments as activity and picking the latest dispatch attempt are good fixes, but the discovery query no longer validates against GitHub, the shared timeline window can now lose the events the trust decisions depend on, and two closure-policy changes need a decision of their own. The branch also conflicts with main after #76835, #76836, #76837 and #76839 merged, so it needs a rebase.
The branch currently conflicts with main and needs a rebase before this can merge.
Blocking — the discovery query no longer validates (dev/breeze/src/airflow_breeze/utils/fork_ci_reconcile.py:951)
itemTypes: [
...
PULL_REQUEST_REVIEW,
PULL_REQUEST_REVIEW_COMMENT # <- not a PullRequestTimelineItemsItemType
]
...
... on PullRequestReviewComment { createdAt author { login } }
GitHub rejects this query. Running the same selection against apache/airflow returns Argument 'itemTypes' on Field 'timelineItems' has an invalid value (... PULL_REQUEST_REVIEW_COMMENT). Expected type '[PullRequestTimelineItemsItemType!]' and Fragment on PullRequestReviewComment can't be spread inside PullRequestTimelineItems. This selection is used by discovery before any pull request is reconciled, and GitHubClient.graphql raises on errors, so the monitor would stop reconciling every gated pull request. The unit tests mock the GraphQL response, so they pass. Inline review comments are reachable on the timeline as PULL_REQUEST_REVIEW_THREAD (or through each PullRequestReview's comments), not as PULL_REQUEST_REVIEW_COMMENT. Whatever the fix, please run the query once against the real API (gh api graphql -F query=@...) before pushing.
Flagged by both the primary and adversarial reviewers.
comments now share the last-100 timeline window with the control events (dev/breeze/src/airflow_breeze/utils/fork_ci_reconcile.py:943)
timelineItems(
last: 100, # <- comments and reviews now compete with BaseRefChanged / Reopened / ConvertToDraft
The window is still last: 100 and unpaginated, but it now also holds every comment and review. On a pull request with a busy conversation, the BaseRefChangedEvent, ReopenedEvent and ConvertToDraftEvent the reconciler depends on drop out of it. Losing a retarget means last_base_change_at stays unset, so a green decision and the gate check made for the old base are reused for the new one, and an author can force that by retargeting and posting enough comments. Losing a reopen makes the reconciler finish a closure the author already undid; losing the convert-to-draft actor makes a bot draft look like the author's. Read the latest human comment or review with a separate query (or comments(last: 1) / reviews(last: 1) on the pull request), and keep the control-event window as it was.
Flagged by both the primary and adversarial reviewers.
two closure rules change under a hardening title (dev/breeze/src/airflow_breeze/utils/fork_ci_reconcile.py:253)
CLOSABLE_STATES = frozenset({ForkState.SETUP_REQUIRED, ForkState.AWAITING_PUSH, ForkState.FAILED})
Two of these changes are policy rather than hardening: pull requests whose fork CI failed now close after 30 days, which the description does not mention, and a pull request whose head repository is deleted is closed instead of being reported, which the description words as if the reconciler already closed such pull requests. Both reverse rules the design document and ADIP-12 state (closure applies only while waiting for the author to set up fork CI or push; a deleted head repository is reported and otherwise left alone). Closing failed also covers an approved pull request whose re-run flaked, which the "failed does not draft" rule was written to protect. These need a maintainer decision, and the ADIP-12 page would change with them. Move the two closure changes into a pull request of their own with the reasoning in its description, so they can be discussed and decided on their own; keep the activity and attempt-ordering fixes here.
Smaller observations
- See inline comments on
dev/breeze/src/airflow_breeze/utils/fork_ci_reconcile.py:646.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. After you've
addressed the points above and pushed an update, an Apache Airflow
maintainer — a real person — will take the next look
at the PR. The findings cite the project's review criteria;
if you think one of them is mis-applied, please reply on the
PR and a maintainer will weigh in.More on how Apache Airflow handles maintainer review:
Contributing guide.
Include PullRequestReview and discussion comments in activity tracking so diff comments and reviews count as human activity, reset the inactivity clock when a new commit SHA is pushed, and verify head repository availability via the REST API before reporting deleted forks as unknown. Case-fold bot logins so triage bots do not prevent inactive pull requests from closing, sort workflow_dispatch check suites by run attempt, separate timeline control events from comments/reviews in the discovery query, and allow authors to reopen gate_modified pull requests once gate changes are removed.
3b1c4f5 to
74fdef4
Compare
potiuk
left a comment
There was a problem hiding this comment.
Thanks, all four points are addressed: the pass-two selection validates against the API (I ran it once against this pull request), comments and reviews are read outside the control-event window, both closure-policy changes are reverted, and nothing closes on the head-repository check any more.
A few optional clean-ups:
check_head_repo_unavailablenow only chooses between two "unknown" messages, at the cost of a REST call every run for each pull request with a missing head repository. It could go, or at least catch the client's error type rather thanException.state_comment(fork: str | None = None)andfork=pr.head_repo or ""in the inactivity close are left over from the reverted closure;head_repocan no longer beNonethere.- The comment above
reopened_since_closingstill says only a maintainer's reopen lifts a gate closure. Forgate_modifiedthe author's reopen counts now (safe, since the gate is re-checked on the reopened head). Please also mention this in the PR description, as it changes the documented recovery path.
Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting
Backport successfully created: v3-4-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…ules (#76956) (#77124) Include PullRequestReview and discussion comments in activity tracking so diff comments and reviews count as human activity, reset the inactivity clock when a new commit SHA is pushed, and verify head repository availability via the REST API before reporting deleted forks as unknown. Case-fold bot logins so triage bots do not prevent inactive pull requests from closing, sort workflow_dispatch check suites by run attempt, separate timeline control events from comments/reviews in the discovery query, and allow authors to reopen gate_modified pull requests once gate changes are removed. (cherry picked from commit febd7b4) Co-authored-by: Ayush Meel <ayushmeel.dev@gmail.com>
Description
Part of AIP-120:
The reconciler had a few edge cases where it closed pull requests that were actually still active:
failed.headRepository: nullon transient GraphQL glitches, the reconciler closed the PR immediately instead of checking if the repo was actually gone.workflow_dispatchre-runs with multiple attempts didn't always pick up the latest attempt.Airflow-Triage-Botwere treated as humans and kept dead PRs open.This change:
PullRequestReviewandPullRequestReviewCommentin activity tracking so diff comments and reviews count as activity.setup_requiredandawaiting_pushso PRs with ongoing conversations don't get auto-closed.Airflow-Triage-Botorcodecovdon't prevent inactive PRs from closing.workflow_dispatchcheck suites by(createdAt, runAttempt)so re-runs resolve to the latest attempt.gate_modifiedPRs once the gate changes are reverted.Tests
test_fork_ci_reconcile.pyfor review comments, commit SHA resets, deleted fork REST checks, bot case-folding, and dispatch attempt ordering.test_fork_ci_messages.py.Was generative AI tooling used to co-author this PR?