-
Notifications
You must be signed in to change notification settings - Fork 20
feat: allow per-PR fix-loop budget via label #1042
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
4
commits into
fullsend-ai:main
Choose a base branch
from
Benkapner:feat/fix-budget-label
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.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0c6fdef
feat: allow per-PR fix-loop budget via label
Benkapner e8cc242
fix: scope fix-budget label to the bot cap and address review findings
Benkapner cc462ec
fix: document PR_LABELS activation without shared env.runner
Benkapner 0d5fc9e
fix: correct PR_LABELS activation recipe and test post-fix budget mirror
Benkapner 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
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
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
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
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,52 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck shell=bash | ||
| # fix-budget.lib.sh — parse a per-PR fix-loop budget from PR labels. | ||
| # | ||
| # A label of the form `fullsend-fix-budget/N` (N a positive integer) lets a | ||
| # maintainer cap the review->fix loop for a single PR below the global | ||
| # iteration cap. The label can only TIGHTEN the cap, never raise it: | ||
| # enforcement lives in pre-fix, which applies min(label_budget, cap). | ||
| # | ||
| # Bundled into pre-fix.sh via bundle-sh.sh. | ||
| # | ||
| # Expected env vars (optional): | ||
| # PR_LABELS — PR label names separated by commas and/or newlines. Absent/empty | ||
| # is fine: parse_fix_budget then returns nothing and the cap is | ||
| # unchanged. (The upstream dispatcher comma-joins labels; a | ||
| # newline-joined value is also accepted.) | ||
|
|
||
| [[ -n "${FIX_BUDGET_SH_LOADED:-}" ]] && return 0 | ||
| FIX_BUDGET_SH_LOADED=1 | ||
|
|
||
| FIX_BUDGET_LABEL_PREFIX="fullsend-fix-budget/" | ||
|
|
||
| # parse_fix_budget [labels] | ||
| # Reads label names (arg 1, or PR_LABELS env when omitted) separated by commas | ||
| # and/or newlines. Echoes the smallest valid budget found, or nothing when no | ||
| # valid label is present. A malformed value (non-integer, zero, negative) is | ||
| # ignored, not fatal — a bad label must not silently drop the existing cap. | ||
| parse_fix_budget() { | ||
| local labels="${1-${PR_LABELS:-}}" | ||
| local best="" label n | ||
| # Accept comma-joined labels (the upstream dispatcher format) as well as | ||
| # newline-joined: normalize commas to newlines before splitting. | ||
| labels="${labels//,/$'\n'}" | ||
| while IFS= read -r label; do | ||
|
Comment on lines
+28
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5. Feature lacks linked authorization This PR adds a new parser, runtime guard, generated bundle changes, and tests well beyond the rule's 20-line threshold, but the PR metadata contains no linked authorizing issue. The non-trivial feature therefore lacks the required explicit authorization. Agent Prompt
|
||
| # Trim surrounding whitespace so " fullsend-fix-budget/3 " still matches. | ||
| label="${label#"${label%%[![:space:]]*}"}" | ||
| label="${label%"${label##*[![:space:]]}"}" | ||
| [[ "${label}" == "${FIX_BUDGET_LABEL_PREFIX}"* ]] || continue | ||
| n="${label#"${FIX_BUDGET_LABEL_PREFIX}"}" | ||
| # Bound the digit count. An arbitrarily long value would overflow Bash's | ||
| # signed 64-bit arithmetic in the `-lt` comparison (e.g. 2^64 evaluates as | ||
| # 0), which would look "tighter" than any cap and block every fix run. | ||
| # A budget above 99999 is meaningless next to caps of 5/10, so treat an | ||
| # over-long value as malformed and ignore it. | ||
| [[ "${n}" =~ ^[1-9][0-9]{0,4}$ ]] || continue | ||
| if [[ -z "${best}" || "${n}" -lt "${best}" ]]; then | ||
| best="${n}" | ||
| fi | ||
| done <<< "${labels}" | ||
| [[ -n "${best}" ]] && printf '%s\n' "${best}" | ||
| return 0 | ||
| } | ||
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,40 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck shell=bash | ||
| # review-labels.lib.sh — recognize pipeline-managed "control" labels. | ||
| # | ||
| # Control labels are set by the review pipeline (or a maintainer, for the | ||
| # fix-budget knob), not by the review agent. post-review refuses to add or | ||
| # remove them via agent-recommended label_actions. Kept in a sourceable lib so | ||
| # the same definition is exercised by both production and the unit test — a | ||
| # duplicated copy in the test would pass even if the production branch drifted. | ||
| # | ||
| # Bundled into post-review.sh via bundle-sh.sh. | ||
|
|
||
| [[ -n "${REVIEW_LABELS_SH_LOADED:-}" ]] && return 0 | ||
| REVIEW_LABELS_SH_LOADED=1 | ||
|
|
||
| REVIEW_CONTROL_LABELS=( | ||
| "ready-for-merge" "requires-manual-review" "rejected" | ||
| "ready-for-review" "fullsend-no-fix" "fullsend-fix" | ||
| ) | ||
|
|
||
| # is_control_label LABEL — return 0 if LABEL is pipeline-managed, 1 otherwise. | ||
| is_control_label() { | ||
| local label="$1" | ||
| local cl | ||
| for cl in "${REVIEW_CONTROL_LABELS[@]}"; do | ||
| if [[ "${cl}" == "${label}" ]]; then | ||
| return 0 | ||
| fi | ||
| done | ||
| # Pipeline-managed label prefixes. | ||
| if [[ "${label}" == risk/* ]]; then | ||
| return 0 | ||
| fi | ||
| # Maintainer-set fix-loop budget (fullsend-fix-budget/N); pipeline-managed so | ||
| # the review agent preserves it rather than treating it as a contextual label. | ||
| if [[ "${label}" == fullsend-fix-budget/* ]]; then | ||
| return 0 | ||
| fi | ||
| return 1 | ||
| } |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6. Protected scripts require human approval
📜 Skill insight§ ComplianceAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools