Skip to content

fix(budget-breaker): lengthen the early exit's default slot from two minutes to ten - #2307

Merged
don-petry merged 3 commits into
mainfrom
claude/breaker-slot-default
Oct 11, 2026
Merged

don-petry merged 3 commits into
mainfrom
claude/breaker-slot-default

Conversation

@don-petry

@don-petry don-petry commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

"feat(budget-breaker): wake on agent workflow runs" (#2293) estimated about 47 breaker runs an hour. The first 84 minutes of real runs showed 309 created and 115 executed (about 82 an hour), with no self-trigger loop: fleet activity is much burstier than the daily average the estimate used. With a two-minute early-exit slot, that is up to 30 organisation scans an hour on the maintainer login's shared API quota, for a breaker that is disarmed and decided none every time. Measurements are on #2259.

Design

One default changes: BUDGET_BREAKER_MIN_INTERVAL_MIN goes from 2 to 10 minutes when the repository variable is unset. Nothing else about the early exit changes.

  • At most 6 organisation scans an hour instead of 30. The two cheap calls of a run that exits early are unchanged.
  • A quota marker posted in this repository still makes the next run decide at once (the early exit's own check).
  • A marker posted only in another repository is read by the first run of the next slot: up to ten minutes later instead of two.
  • The number of runs created does not change. Only a different trigger can change that; filed as Budget breaker: wake it only when there is something to decide, instead of on every Dev-Lead Agent run #2306.

The maintainer chose this over leaving it for a day or reverting #2293.

Risk

  • A trip driven only by other repositories' markers can be up to eight minutes slower than before. The decision still looks at a 30-minute window, so evidence is not lost.
  • During a real quota event with markers in this repository, every run in the slot scans (the early exit does not apply). That was already true; a longer slot does not make it worse.
  • The breaker is disarmed and BUDGET_BREAKER_ARMED is unset.

Test plan

  • tests/dev-lead/unit/test_budget_breaker_writer.bats: 97 of 97. The default-slot assertions now expect ten minutes; the tunable test sets two explicitly, and gains two cases for the default: a wake-up 590 seconds into the slot exits early on a run created at its start, and one 610 seconds in (the next slot) decides.
  • shellcheck --severity=warning -x clean.

Rollback

Revert, or set the repository variable BUDGET_BREAKER_MIN_INTERVAL_MIN to 2.

Monitoring

Breaker run logs: the share of runs that print early exit should rise, and quota markers read should appear at most six times an hour outside a quota event.

Refs #2259

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

…minutes to ten

The first 84 minutes under the workflow_run trigger created 309 runs and
executed 115, far above the estimate, because fleet activity is burstier than
its daily average. A two-minute slot allowed up to 30 organisation scans an hour
on the shared maintainer login while the breaker is disarmed. Ten minutes allows
6. A marker in this repository still makes the next run decide at once; one
posted only elsewhere waits for the next slot.

Refs #2259

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@don-petry don-petry added the dev-lead:hands-off Exclude from dev-lead agent automation label Oct 11, 2026
@don-petry
don-petry marked this pull request as ready for review October 11, 2026 19:08
@don-petry
don-petry requested a review from a team as a code owner October 11, 2026 19:08
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 83239dea-0b41-4e96-b67a-a80e83a87ef9

📥 Commits

Reviewing files that changed from the base of the PR and between 76d30cd and 4c6ef49.


📒 Files selected for processing (3)
  • AGENTS.md
  • scripts/budget_breaker.sh
  • tests/dev-lead/unit/test_budget_breaker_writer.bats

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request increases the default value of BUDGET_BREAKER_MIN_INTERVAL_MIN from 2 to 10 minutes across the documentation, script implementation, and unit tests. This change is intended to reduce the frequency of organization scans and conserve API quota. No review comments were provided, so there is no additional feedback to address.

Comment thread scripts/budget_breaker.sh Resolved
@codeant-ai

codeant-ai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; the change raises the early-exit default to ten minutes while scheduled runs still scan as a backstop.
  • The updated tests cover the ten-minute default, custom intervals, and invalid-value fallback.

Assessed commit: 4c6ef4917697

@don-petry

Copy link
Copy Markdown
Collaborator Author

dev-lead is withholding action on this item.

It is labeled dev-lead:hands-off (deliberately kept off-limits to dev-lead (e.g. changes to the dev-lead automation itself)), so dev-lead will not pick it up while that label is present. This notice is posted once so the withhold is visible rather than looking like a stalled run.

To re-enable automated pickup: remove the dev-lead:hands-off label.

@don-petry

Copy link
Copy Markdown
Collaborator Author

QA Lead — test-risk advisory

Risk tier: LOW. This PR changes one default (2 → 10 minutes) in a breaker that is not armed. Setting a repository variable rolls it back, and the new default is tested on both sides of the slot boundary.

What I'd shore up (highest leverage first):

  • Strengthen the 610-second assertion. The "next slot decides" case only checks != *"early exit"*. It would still pass if the run failed open for an unrelated reason, for example because the earlier runs could not be read. Make it assert what the sibling cases assert: decision: trip (evidence_count=3) and, ideally, scanned. Then the test proves the run decided, not just that it didn't exit early.
  • Make the fixture's 10-minute alignment explicit. The 590/610 boundary only works because NOW=1791633600 happens to be a multiple of 600. The helper comment (line ~175) and the comment at line ~2305 still say "start of a two-minute slot". Correct those comments and add a one-line guard ((( NOW % 600 == 0 ))) so a future change to NOW can't quietly move the boundary.
  • Pin down the accepted cost. The PR accepts that a quota marker posted only in another repository is read up to ~10 minutes later. Add one default-slot case: a marker exists only in a foreign repository and the wake-up falls in a covered slot, so the run exits early. The test then records that trade-off on purpose, and any change to it will fail loudly instead of drifting.
  • Post-merge check: the monitoring plan is good. Confirm that quota markers read appears at most 6 times per hour before anyone arms the breaker.

Escalate? No.

Advisory only — I comment, I do not change code. Ground: BMAD Test Architecture
(bmad-tea v1.19.0). Opt out on this item with the qa-lead:hands-off label.

@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-10-11T20:19:04Z.

don-petry and others added 2 commits October 11, 2026 15:54
…s slot alignment, and state scans from scheduled ticks

From review: the 610-second case only showed the run did not exit early; it now
shows it scanned and decided. The fixture's clock must be a multiple of 600 for
the default slot, which is now checked. And the documentation said at most six
organisation scans an hour; that is from event wake-ups, and each delivered
scheduled tick adds one.

Refs #2259

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@don-petry

Copy link
Copy Markdown
Collaborator Author

Review round 1, head 4c6ef491. From the QA advisory: the 610-second case now asserts the run scanned and decided (decision: trip), not only that it did not exit early; the fixture clock's alignment to the ten-minute slot is checked when the file loads, and the two comments that still said "two-minute slot" are corrected. The accepted cost (a marker only in another repository waits for the next slot) is what the default early-exit test already exercises: its markers are all in a foreign repository and the run exits early; a comment now says so. From CodeAnt: the scan ceiling is stated as 6 from event wake-ups plus one per delivered scheduled tick. Full writer suite 97 of 97.

@sonarqubecloud

Copy link
Copy Markdown

@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-10-11T22:04:39Z.

@don-petry
don-petry merged commit 5797da5 into main Oct 11, 2026
71 of 77 checks passed
@don-petry
don-petry deleted the claude/breaker-slot-default branch October 11, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev-lead:hands-off Exclude from dev-lead agent automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants