Skip to content

Let Libra's approval merge docs-engineering PRs - #5051

Draft
reakaleek wants to merge 1 commit into
mainfrom
exclude-docs-engineering-f61ae8f2
Draft

reakaleek wants to merge 1 commit into
mainfrom
exclude-docs-engineering-f61ae8f2

Conversation

@reakaleek

Copy link
Copy Markdown
Member

A PR from a docs-engineering member can merge on Libra's approval alone, and a PR from anyone else still needs a docs-engineering approval. This adds the team-review status that makes that rule checkable. A later ruleset change makes it required.

Affects: Automation

Prompt summary: Require reviews only from contributors outside @elastic/docs-engineering, because Libra already reviews the team's own PRs. Outside contributors still need a docs-engineering review. Auto-merge has to work for the team's PRs.

Why

The main ruleset requires a code-owner review, and .github/CODEOWNERS names @elastic/docs-engineering. A GitHub App such as Libra cannot be a code owner, so its approval never satisfies that rule. Every recent PR, such as #5043, also needed a human approval. A bypass actor does not help, because auto-merge never applies a bypass.

What

A team-review status on every PR

The status passes when a docs-engineering member or dependabot[bot] opened the PR. Otherwise it passes only when a docs-engineering member approved the current head commit. A push moves the head commit, so an approval from before the push no longer counts.

Review events reach the status through a second workflow

A pull_request_review run from a fork gets no secrets, so it cannot read team membership. team-review-trigger.yml only uploads the PR number. team-review.yml then runs from the base branch through workflow_run, validates the number, and sets the status. Neither workflow checks out PR code.

Team membership comes from one API call

The workflow lists @elastic/docs-engineering once and matches the author and the approvers against that list. It mints a token from the existing OBS_AUTOMATION_APP_ID app with members: read.

zizmor.yml lists the new workflow

team-review.yml joins the intentional pull_request_target and workflow_run workflows, and the comment above the list says why.

Risk: The workflow only posts a status. Nothing requires it yet, so it cannot block a merge. If OBS_AUTOMATION lacks the org members: read permission, the token step fails and the run shows red until an org admin adds it. I could not read that app's permissions.

Out of scope: The ruleset change. After this merges and team-review has run green on main, the main ruleset (id 3274800) drops require_code_owner_review and requires team-review. Updatecli PRs come from an app, not dependabot[bot], so they would fail the check until their author is added to the trusted list. Whether Libra's approval counts toward the one required approval is not yet proven.

The `main` ruleset requires a code-owner review, and a GitHub App such as Libra cannot be a code owner. Every PR therefore waits for a human approval, even after Libra approves.

A new required `team-review` status replaces that rule. It passes when a docs-engineering member or `dependabot[bot]` opened the PR. Otherwise it passes only when a docs-engineering member approved the current head commit. `team-review-trigger.yml` hands review events to `team-review.yml`, because a fork review gets no secrets.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Comment on lines +21 to +23
concurrency:
group: team-review-${{ github.event.pull_request.number || github.event.workflow_run.id }}
cancel-in-progress: false

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P2 (Medium)

The concurrency group does not serialize evaluations of the same PR. Runs triggered by workflow_run are keyed by workflow_run.id, so a review-triggered run and a pull_request_target run for the same PR (or two review runs) can run at the same time. Each one reads the reviews and then POSTs the status on its own schedule. A slower run that saw an approval can post success after a newer run already posted failure for a dismissal or a changes-requested review. The head commit then keeps a stale green team-review, and once the status is required that can let a PR merge without a valid approval. Consider re-reading the reviews right before posting, or passing a per-PR key into a separate concurrency-limited job after the PR number is resolved.

Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.

Comment on lines +80 to +85
# Latest review per reviewer, on the current head commit, that approves.
approvers=$(gh api --paginate "repos/$REPO/pulls/$pr_number/reviews" \
--jq '.[] | select(.state != "COMMENTED") | [.user.login, .state, .commit_id] | @tsv' \
| awk -F'\t' -v sha="$head_sha" '{ latest[$1] = ($2 == "APPROVED" && $3 == sha) } END { for (u in latest) if (latest[u]) print u }')
for user in $approvers; do
if is_member "$user"; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

The new merge decision has no automated coverage for review ordering and head changes. Add cases showing that a later comment preserves an approval, while a dismissal or a new head invalidates it, so edits to the filter can't silently weaken the gate.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Comment on lines +93 to +94
gh api -X POST "repos/$REPO/statuses/$head_sha" \
-f state="$state" -f context=team-review -f description="$description"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P2 (Medium)

team-review evaluates a PR but publishes its verdict on a commit shared by any PR with that head SHA. Once the status is required, GitHub can count a success from one PR toward another PR that has no team approval of its own. Enforce the policy with a check bound to the individual PR, not a shared head status.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

@reakaleek
reakaleek marked this pull request as draft November 25, 2026 11:06

This branch was successfully deployed

1 active deployment
assembler-preview — ab39dbb3 Deployed Nov 25, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation packaging, ci/cd.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants