-
Notifications
You must be signed in to change notification settings - Fork 73
feat(eval): add rework rate tracking script for agent PRs (#5516) #5517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Benkapner
wants to merge
3
commits into
fullsend-ai:main
Choose a base branch
from
Benkapner:feat/rework-rate-tracking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−0
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| #!/usr/bin/env bash | ||
| # Calculate rework rate for agent-authored PRs. | ||
| # | ||
| # Usage: ./scripts/rework-rate.sh [REPO] [DAYS] [FOLLOWUP_DAYS] | ||
| # | ||
| # REPO - GitHub repo (default: fullsend-ai/fullsend) | ||
| # DAYS - Look back window for merged PRs (default: 30) | ||
| # FOLLOWUP_DAYS - Window after merge to check for human follow-ups (default: 7) | ||
| # | ||
| # Requires: gh CLI authenticated with repo access, jq | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPO="${1:-fullsend-ai/fullsend}" | ||
| DAYS="${2:-30}" | ||
| FOLLOWUP_DAYS="${3:-7}" | ||
|
|
||
| SINCE=$(date -d "-${DAYS} days" +%Y-%m-%dT00:00:00Z 2>/dev/null || date -v-${DAYS}d +%Y-%m-%dT00:00:00Z) | ||
|
|
||
| echo "Rework Rate Report" | ||
| echo "Repository: ${REPO}" | ||
| echo "Window: last ${DAYS} days (since ${SINCE})" | ||
| echo "Follow-up window: ${FOLLOWUP_DAYS} days after merge" | ||
| echo "" | ||
|
|
||
| # Fetch merged PRs by bot authors | ||
| BOT_PRS=$(gh api "search/issues?q=repo:${REPO}+is:pr+is:merged+author:app/fullsend-ai-coder+merged:>=${SINCE}&per_page=100&sort=created&order=desc" \ | ||
| --jq '.items[] | {number: .number, title: .title, closed_at: .closed_at}') | ||
|
|
||
| if [ -z "$BOT_PRS" ]; then | ||
| echo "No agent PRs found in the last ${DAYS} days." | ||
| exit 0 | ||
| fi | ||
|
|
||
| TOTAL=0 | ||
| REWORKED=0 | ||
| REWORKED_LIST="" | ||
|
|
||
| while IFS= read -r pr_json; do | ||
| PR_NUM=$(echo "$pr_json" | jq -r '.number') | ||
| PR_TITLE=$(echo "$pr_json" | jq -r '.title') | ||
| MERGED_AT=$(echo "$pr_json" | jq -r '.closed_at') | ||
| TOTAL=$((TOTAL + 1)) | ||
|
|
||
| # Get files changed in this PR | ||
| PR_FILES=$(gh api "repos/${REPO}/pulls/${PR_NUM}/files?per_page=100" \ | ||
| --jq '.[].filename' 2>/dev/null || echo "") | ||
|
|
||
| if [ -z "$PR_FILES" ]; then | ||
| continue | ||
| fi | ||
|
|
||
| # Check for human commits touching the same files after merge | ||
| FOLLOWUP_UNTIL=$(date -d "${MERGED_AT} +${FOLLOWUP_DAYS} days" +%Y-%m-%dT23:59:59Z 2>/dev/null \ | ||
| || date -j -f "%Y-%m-%dT%H:%M:%SZ" "${MERGED_AT}" -v+${FOLLOWUP_DAYS}d +%Y-%m-%dT23:59:59Z 2>/dev/null \ | ||
| || echo "") | ||
|
|
||
| if [ -z "$FOLLOWUP_UNTIL" ]; then | ||
| continue | ||
| fi | ||
|
|
||
| # Get commits after merge by non-bot authors | ||
| FOLLOWUP_COMMITS=$(gh api "repos/${REPO}/commits?since=${MERGED_AT}&until=${FOLLOWUP_UNTIL}&per_page=100" \ | ||
| --jq '[.[] | select(.author.type != "Bot" and .author.login != "fullsend-ai-coder[bot]" and .author.login != "fullsend-ai-fullsend[bot]") | {sha: .sha, author: .author.login, message: .commit.message}]' 2>/dev/null || echo "[]") | ||
|
rh-hemartin marked this conversation as resolved.
Outdated
|
||
|
|
||
| if [ "$FOLLOWUP_COMMITS" = "[]" ] || [ -z "$FOLLOWUP_COMMITS" ]; then | ||
| continue | ||
| fi | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Check if any follow-up commit touches the same files | ||
| FOUND_REWORK="" | ||
| while IFS= read -r commit_json; do | ||
| COMMIT_SHA=$(echo "$commit_json" | jq -r '.sha') | ||
| COMMIT_AUTHOR=$(echo "$commit_json" | jq -r '.author') | ||
|
|
||
| COMMIT_FILES=$(gh api "repos/${REPO}/commits/${COMMIT_SHA}" \ | ||
| --jq '.files[].filename' 2>/dev/null || echo "") | ||
|
|
||
| OVERLAP=$(comm -12 <(echo "$PR_FILES" | sort) <(echo "$COMMIT_FILES" | sort) 2>/dev/null || echo "") | ||
|
|
||
| if [ -n "$OVERLAP" ]; then | ||
| FOUND_REWORK="yes" | ||
| REWORKED_LIST="${REWORKED_LIST}\n #${PR_NUM} - ${PR_TITLE}\n Follow-up: ${COMMIT_SHA:0:7} by @${COMMIT_AUTHOR} (same files: $(echo "$OVERLAP" | head -3 | tr '\n' ', '))" | ||
| break | ||
| fi | ||
| done < <(echo "$FOLLOWUP_COMMITS" | jq -c '.[]') | ||
|
|
||
| if [ -n "$FOUND_REWORK" ]; then | ||
| REWORKED=$((REWORKED + 1)) | ||
| fi | ||
| done < <(echo "$BOT_PRS" | jq -c '.') | ||
|
|
||
| if [ "$TOTAL" -eq 0 ]; then | ||
| RATE="0.0" | ||
| else | ||
| RATE=$(awk "BEGIN {printf \"%.1f\", ($REWORKED / $TOTAL) * 100}") | ||
| fi | ||
|
|
||
| echo "Agent PRs merged (last ${DAYS} days): ${TOTAL}" | ||
| echo "Reworked by humans: ${REWORKED}" | ||
| echo "Rework rate: ${RATE}%" | ||
|
|
||
| if [ -n "$REWORKED_LIST" ]; then | ||
| echo "" | ||
| echo "Reworked PRs:" | ||
| echo -e "$REWORKED_LIST" | ||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.