Skip to content

feat(org-status): add Needs Rebase column to daily PR table#231

Merged
don-petry merged 6 commits into
mainfrom
claude/investigate-compliance-prs-6ojvJ
May 10, 2026
Merged

feat(org-status): add Needs Rebase column to daily PR table#231
don-petry merged 6 commits into
mainfrom
claude/investigate-compliance-prs-6ojvJ

Conversation

@don-petry
Copy link
Copy Markdown
Contributor

@don-petry don-petry commented May 10, 2026

Summary

Adds a Needs Rebase column to the existing per-repo open-PRs table in the daily org status report. Reporting only — no automated rebase or comments.

Changes

scripts/org_status.sh:

  • GraphQL query now selects headRefName / baseRefName on each open PR.
  • New pass calls GET repos/{repo}/compare/{base}...{head} per PR to compute behind_by; PRs with behind_by > 0 are tagged needsRebase: true.
  • PR_BY_REPO aggregation gains a needs_rebase count.
  • Prompt updated: per-repo breakdown table now includes a Needs Rebase column rendering N 🔄 when count > 0, otherwise.

Why

Most open compliance PRs that aren't merging are either behind main or actively conflicting. The daily report previously gave no signal of this — surfacing it in the existing PR table makes the drift visible without adding a new table or any automated action.

What was removed

A first iteration of this PR tried to close the loop by:

  1. Posting @claude comments on stale PRs from daily-org-status.yml
  2. Adding an @claude fallback to auto-rebase-reusable.yml when update-branch fails with the missing workflows permission

Manual validation on #213 (job 25635994899) confirmed that claude-code-action cannot perform branch operations (rebase / merge / history rewrite), so the agentic fallback would never have worked. Both of those changes have been reverted; this PR is now scoped to surfacing the signal only. A follow-up can wire in a GH_PAT_WORKFLOWS-based retry in auto-rebase-reusable.yml if/when that becomes the right next step.

Test plan

…allback

- org_status.sh: query headRefName/baseRefName, compute behind_by per PR
  via the REST compare API, surface a Needs Rebase column in the existing
  per-repo open-PRs table, and emit /tmp/needs-rebase.json for the
  follow-up commenter.
- daily-org-status.yml: post an idempotent @claude rebase request on each
  stale PR (sentinel <!-- claude-rebase-request -->) using GH_PAT_WORKFLOWS
  so the comment author is OWNER and the Claude reusable workflow fires.
- auto-rebase-reusable.yml: when update-branch is blocked by the missing
  workflows permission, post an @claude rebase request via GH_PAT_WORKFLOWS
  (sentinel <!-- auto-rebase-claude-request -->); fall back to the original
  manual-rebase comment when GH_PAT_WORKFLOWS is unset.
- standards/workflows/auto-rebase.yml: document the optional GH_PAT_WORKFLOWS
  secret that enables the @claude fallback for consumer repos.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Warning

Rate limit exceeded

@don-petry has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 32 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5100ff1b-31cc-4af4-8ec2-9663fa1707e8

📥 Commits

Reviewing files that changed from the base of the PR and between dcf3caf and 953a375.

📒 Files selected for processing (1)
  • scripts/org_status.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/investigate-compliance-prs-6ojvJ

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

Auto-rebase blocked — the base branch contains .github/workflows/ changes that require the workflows permission to merge into this branch, but the auto-rebase workflow's token does not have that permission.

Please rebase this branch manually:

git fetch origin
git rebase origin/main
git push --force-with-lease

claude added 2 commits May 10, 2026 18:39
Following manual validation, @claude cannot perform branch operations
(rebase/merge/history rewrite), so the agentic rebase fallback in #231
will not work. Reduce the PR to its reporting-only core:

- Revert .github/workflows/auto-rebase-reusable.yml and
  standards/workflows/auto-rebase.yml to main.
- Revert .github/workflows/daily-org-status.yml (drop the @claude
  comment step, pull-requests: write permission, REBASE_LIST_FILE env).
- scripts/org_status.sh: drop the /tmp/needs-rebase.json sidecar;
  keep the behind_by detection and Needs Rebase column in the existing
  per-repo open-PRs table.
@don-petry don-petry changed the title feat(auto-rebase): detect stale PRs in daily status and add @claude fallback feat(org-status): add Needs Rebase column to daily PR table May 10, 2026
@don-petry don-petry marked this pull request as ready for review May 10, 2026 18:58
@don-petry don-petry requested a review from a team as a code owner May 10, 2026 18:58
Copilot AI review requested due to automatic review settings May 10, 2026 18:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds “Needs Rebase” signal to the daily org status report’s per-repo open PR breakdown by computing whether each open PR branch is behind its base branch.

Changes:

  • Extends the PR GraphQL query to capture headRefName / baseRefName.
  • Adds a per-PR REST compare pass to compute behind_by and flags PRs as needsRebase.
  • Updates the per-repo aggregated PR counts and prompt format to include a “Needs Rebase” column.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/org_status.sh
Comment thread scripts/org_status.sh Outdated
Comment on lines +119 to +129
AUGMENTED='[]'
while IFS= read -r pr; do
[ -z "$pr" ] && continue
pr_repo=$(echo "$pr" | jq -r '.repo')
pr_head=$(echo "$pr" | jq -r '.headRefName')
pr_base=$(echo "$pr" | jq -r '.baseRefName')
behind=$(gh api "repos/${pr_repo}/compare/${pr_base}...${pr_head}" --jq '.behind_by' 2>/dev/null || echo 0)
[[ "$behind" =~ ^[0-9]+$ ]] || behind=0
augmented_pr=$(echo "$pr" | jq --argjson b "$behind" '. + {behindBy: $b, needsRebase: ($b > 0)}')
AUGMENTED=$(jq -n --argjson a "$AUGMENTED" --argjson p "$augmented_pr" '$a + [$p]')
done <<< "$(echo "$ALL_PRS" | jq -c '.[]')"
…lurp

Address Copilot review on PR #231:
- Accumulate one augmented PR per line of NDJSON, then slurp into a single
  array at the end via jq -s '.'. Avoids reparsing a growing array on each
  iteration of the loop, which was O(n^2) in time and memory.
- Replace silent compare-API fallback (|| echo 0) with a warning logged to
  stderr so transient API failures or fork-PR 404s are visible in the
  workflow log instead of silently zeroing behindBy.
@sonarqubecloud
Copy link
Copy Markdown

@don-petry don-petry merged commit 8c23b18 into main May 10, 2026
24 checks passed
@don-petry don-petry deleted the claude/investigate-compliance-prs-6ojvJ branch May 10, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants