Skip to content

feat(pr-pipeline): re-fire at most one budget-stopped issue run per slot - #17508

Merged
kyle-sexton merged 4 commits into
mainfrom
feat/refire-budget-per-slot
Nov 19, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
feat/refire-budget-per-slot

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Refs: #17460

Summary

After a GitHub token budget reset, the work-unblock sweep re-fired budget-stopped issue-lane runs at the general rate of two per slot (limits.refire-queue-per-slot: 2, owner decision Q109). The run re-fired as the second one per slot often waited 20 to 47 minutes for one of the 3 slots, past the 20-minute window after the reset (FLOOR_SPAN_MIN), so the start gate stopped it again and it waited another hour. On 2026-11-19, 17 of 48 budget stops came after a slot wait of 20 minutes or more.

Owner decision: https://github.com/melodic-software/architecture/blob/c3a36f0e86c268cd6a427abd344c69d76c03d654/docs/owner-decisions.md#L237. Owner, verbatim: "Go with recommendations." Decision: in each 20-minute window after a GitHub token budget reset, the work-unblock sweep re-fires at most one budget-stopped issue-lane run per slot. Every other re-fire keeps Q109's two per slot, and the start gate, the window and the budget pacing are unchanged.

Part of #17460 this delivers

#17460's first done-when item is "Spend is paced across the hour". This PR delivers one piece of that pacing: the re-fires of budget-stopped runs after a reset. Today a second re-fire per slot queues past the 20-minute window, its start gate stops it on the budget again, and it is re-fired an hour later, so the same issue spends its start-up calls in two or more hours. Capping these re-fires at one per slot lets each one start inside its window, which removes those repeat stops and the calls they spend. It changes no consumer and no dispatch path, so it does not by itself meet that done-when item.

Fix

  • New limits.refire-budget-per-slot (default 1, from 1 to 10). It is set in docs/conventions/pr-pipeline.yaml with a comment linking the decision, and added to the schema, to resolve-config's limitsOf and to the lane scripts' LIMIT_DEFAULTS.
  • label-unblocked.mjs: in the same try as the existing kill-switch room, the sweep computes a budget-stop room as refire-budget-per-slot × SLOTS minus the unfinished lane runs (stale queued runs are left out, as they already are). A budget-stopped item, stall === "breaker" with trip.budget, needs both rooms. When the budget room is spent, the item is deferred before it takes any of the shared room, so switch trips and upstream-status re-fires still fill two per slot. Every switch-trip or upstream-status re-fire the sweep accepts also spends budget room, so one that sorts ahead of a budget stop counts toward the budget target (review finding). If the listing fails, the budget room stays at 0, the same as the existing hold. The sweep logs the budget room and each deferral with its own line.
  • README limits table row and header comment updated. Changelog fragment .changes/pr-pipeline/feat-refire-budget-per-slot-7c2e4a91.md (minor bump).

Verification

  • node --test on label-unblocked.test.mjs: 465 of 465 pass at the new head. Earlier, label-unblocked.test.mjs, resolve.test.mjs, live-config.test.mjs and resolve-config.test.mjs: 765 of 765 pass. Also pr-unblock/dispatch, dependency-dispatch, feedback-dispatch and work-resolve-issue/report-outcome, which read the limit defaults: 794 of 794 pass.
  • New tests use 3 slots and a sweep at 12:00, inside the window that opened at the 11:50 reset:
    • 5 budget-stopped issues with 0, 2 or 3 unfinished runs re-fire 3, 1 and 0 of them, oldest run end first. 2 issues re-fire both.
    • 4 budget-stopped issues plus 4 switch trips re-fire 3 budget issues and then 3 switch trips (room 6). 4 switch trips with 2 unfinished runs still re-fire 4.
    • 3 switch trips whose runs ended before 3 budget stops' re-fire the 3 switch trips and defer every budget stop.
    • refire-budget-per-slot: 2 with refire-queue-per-slot: 3 and 2 unfinished runs re-fires 4 of 5.
    • resolve.test.mjs accepts 2 and rejects 0, 11 and 1.5.
  • The new tests were checked against broken versions of the code. With the cap removed, all three sweep tests fail. With a deferred budget item taking shared room, the mixed test fails (5 restarts instead of 6). Without the switch-trip spend of budget room, the switch-trips-first test fails.

Remaining for #17460

These done-when items stay open for later work:

  • No burst dispatch at BRAKE-CLEAR, and running jobs check headroom before each costly phase.
  • Run lists filtered by head SHA in pr-merge.yml.
  • The review starting from Refine's event instead of polling it.
  • reconcile-lost-runs running hourly.
  • The if: gate on pr-dispatch-feedback.
  • A 24 h window with at most a few trips.
  • The before/after calls per hour for each consumer, from limits/gh-job-calls.jsonl.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj

A budget-stopped run re-fired as the second run per slot often waited
20 to 47 minutes for a slot, past the 20-minute window after the token
reset, and the start gate stopped it again. Add
limits.refire-budget-per-slot (default 1): work-unblock re-fires
budget-stopped issues only until the unfinished lane runs reach this
times SLOTS. Those re-fires still count toward refire-queue-per-slot's
room; every other re-fire keeps two per slot. A budget item deferred by
the cap leaves its shared room to switch trips.

Refs: #17460

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 19, 2026 19:52

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4717b2421

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T19:54:43.116960Z c4717b2 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 0a4996a0e4d60c91ab399da686b427d7ddb36e57: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

This lane already reviewed an earlier head (c4717b2), so this review reported only blocking findings. I read the whole diff for all 9 changed files.

The change adds one pacing limit, limits.refire-budget-per-slot (default 1, from 1 to 10). The work-unblock sweep uses it to re-fire fewer budget-stopped issue-lane runs per slot. It only narrows what the sweep re-fires and widens no trust control.

Trusted paths checked:

  • .github/actions/resolve-config/resolve.mjs (token broker signer control): the only change is one new key in limitsOf, "refire-budget-per-slot": limits["refire-budget-per-slot"] ?? 1 (L995). It is a number carried onto the resolved config. It does not change any of these:
    • a token's scope or permissions
    • which lanes or activities get a token
    • an activity's effect
    • a session's allowlist
    • the signer's load path
  • docs/conventions/pr-pipeline.yaml: adds refire-budget-per-slot: 1 under limits. No lane slots, activity effects or merge settings change.
  • .github/scripts/work-resolve-issue/limits.mjs: adds the matching default to LIMIT_DEFAULTS. No merge-hold logic changes.
  • .github/scripts/work-unblock/label-unblocked.mjs (the code the limit gates; not itself a listed trusted path), restartLimited:
    • budgetRoom starts at 0 and is set only after inFlight() lists the runs successfully. It fails closed, the same way the existing room does.
    • New since the last review: a paced item that is not budget-stopped also lowers budgetRoom when it takes shared room. This can only defer more budget-stop re-fires.
    • A budget-stopped item deferred by budgetRoom returns before it takes any shared room. When room is 0 it is still deferred by the existing check.
    • No path adds a re-fire. The kill-switch read, the start gate and restarts-per-run are unchanged.

The schema limits the value to whole numbers from 1 to 10, and the new resolve.test.mjs case shows 0, 11 and 1.5 are rejected.

The settled thread on label-unblocked.mjs (budget room skipped switch-trip re-fires that sort first) is fixed at this head, and I did not raise it again. The PR context contains no embedded directives.

Spend: nothing new. The change lowers the cap on budget-stop re-fires, so the sweep re-fires the same number of issue-lane runs or fewer.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 1 inline finding(s) on c4717b242182e748e4b7c7f5316ecb0d26759a99; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 0a4996a0e4d60c91ab399da686b427d7ddb36e57: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Code review: limits.refire-budget-per-slot (blocking only)

This lane already reviewed an earlier head (c4717b2), so this review reports blocking findings only. I read all 9 changed files in full. I found no blocking findings at 0a4996a.

The earlier finding is fixed. It said switch trips and outage re-fires that sort ahead of budget stops did not spend the budget-stop room. In the re-fire filter, every paced re-fire that is not a budget stop now lowers budgetRoom when it takes shared room (L3003–3005). With 3 slots and 0 unfinished runs, three older switch trips use the budget room of 3, and every budget stop is deferred. The new test at label-unblocked.test.mjs:198 covers that order. The owner resolved that thread with a fix commit.

Other paths I traced in the filter:

  • Budget stop with shared room left but no budget room: deferred with its own log line, and it takes no shared room. So switch trips sorted after it still fill two per slot, which the mixed test covers.
  • Budget stop with no shared room left: falls through to the existing kill-switch deferral.
  • Failed listing: both rooms stay at 0, so nothing paced re-fires. That matches the existing hold.
  • budgetRoom below 0 after switch-trip decrements: still defers, since the check is <= 0.
  • Floor re-fires: these come from the floorStop path, not stall === "breaker", so the budget room does not affect them.
  • trip?.budget: the same check the restart comment already uses at L3076.
  • A resolved config without the new key: the sweep's limits come from readLimits, which lays the config over LIMIT_DEFAULTS (limits.mjs:44). So the key falls back to 1. It is never undefined, which would make the room NaN and fail open.

Config and docs: the default is 1 and the range is 1 to 10 everywhere: the schema, pr-pipeline.yaml, limitsOf, LIMIT_DEFAULTS, the README row and the changelog fragment (minor bump) all agree.

Other checks:

  • Closing issue: none. The PR says only Refs: #17460, so I checked no acceptance criteria.
  • Embedded instructions: none in the PR context, settled threads or prior findings.
  • Verification: the PR body's test counts (465/465, 765/765, 794/794) and its mutation checks are the author's claims. I ran nothing to confirm them.
  • Plugin manifests: none changed, so there are no manifest lines.
  • Loosened checks: the prompt gives no loosened_check_verdict: or loosened_check_patterns: lines, so I used the defaults (fail, no consumer entries). There is no loosened_check_decision_record: line either, so I did not check the citation requirement. The change only makes the re-fire pacing stricter; it loosens nothing.
  • Spend: none added. The change can only defer budget-stop re-fires. It should also cut the repeat start-gate stops, and the start-up calls they spend.

Loosened-check verdict: fail (default, no verdict line in the prompt); nothing loosened.

Verifier dropped 0 of 0 candidates.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

The pr-verify verifier failed head c4717b242182e748e4b7c7f5316ecb0d26759a99. What it wrote, as data:

What it wrote (29 lines)
Summary: Refs #17460. The PR delivers one part of the first done-when item: it paces budget-stop
  re-fires after a reset by adding `limits.refire-budget-per-slot`. The body names that part, lists
  the remaining done-when items, and gives the owner-decision link with the verbatim quote. The new
  limit is wired into the config, the schema, resolve-config, LIMIT_DEFAULTS and the README, and the
  new tests' expected numbers match the code. It fails because the diff does not contain the fix the
  PR body describes. The body says every switch-trip or upstream-status re-fire the sweep accepts
  also spends the budget room. That was a review finding about keeping the queue at one run per
  slot. The body also claims a test where 3 switch trips sorted ahead of 3 budget stops defer every
  budget stop. Neither is in the diff: in `restartLimited`, only a budgeted item decrements
  `budgetRoom`. So when switch or outage re-fires sort ahead of budget stops in the same sweep, the
  budget stops still re-fire up to `refire-budget-per-slot × SLOTS` on top of them. Budget-stopped
  runs then queue as the second run per slot, which is the very problem the change is meant to fix,
  and it breaks the documented "only until the unfinished runs reach this times SLOTS". CI gives no
  evidence either way: `Select Tests` was skipped, so this run ran no suite
  (https://github.com/melodic-software/claude-code-plugins/actions/runs/44624906038/job/135916109556).
  There was no capture.
- PR body: the Fix section says switch-trip and upstream-status re-fires spend budget room, and the
  Verification section lists a 'switch trips ahead of budget stops' test. Neither is in the diff,
  which suggests the head being judged does not include that commit. Push the missing change or
  correct the body.
- .github/scripts/work-unblock/label-unblocked.mjs:2995: when a paced item that is not budgeted (a
  switch trip or outage re-fire) is accepted, also decrement `budgetRoom` (for example, `if
  (paced(item) && room-- > 0) { budgetRoom--; return true; }`, keeping the `!paced` path as it is).
  Without this, re-fires accepted earlier in the same sweep don't count toward the budget target,
  and budget-stopped runs can queue as the second run per slot, past the 20-minute window.
- .github/scripts/work-unblock/label-unblocked.test.mjs:177: add a test where switch trips whose
  runs ended earlier sort ahead of budget stops: 3 switch trips and 3 budget stops with 3 slots and
  0 unfinished should re-fire the 3 switch trips and defer every budget stop. Make sure it fails
  against the current code.

This pull request leaves the merge queue, and ci-status holds it out while it carries pr-verify-failed. A pr-verify pass removes the label, at a new commit or at this same head: once a trusted person edits the body, and only trusted people have edited it since the fail, this head is judged again, so a fail on the body or the issues it links needs only the body fixed, no new commit.

@github-actions github-actions Bot added the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 19, 2026
kyle-sexton and others added 3 commits November 19, 2026 17:02
…e budget-stop room

A switch-trip or upstream-status re-fire that sorted ahead of a budget
stop took shared room without touching the budget-stop room, so budget
stops could still re-fire as the second run per slot. Every accepted
paced re-fire now spends budget-stop room too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj
@github-actions github-actions Bot removed the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 19, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit c13006c Nov 19, 2026
62 checks passed
@kyle-sexton
kyle-sexton deleted the feat/refire-budget-per-slot branch November 19, 2026 23:01
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant