Repository navigation
Keep Account Pooler accounts past the switch threshold usable until the provider refuses them - #6849
Merged
ymichael merged 5 commits intoNov 2, 2026
Conversation
… know The quota store reads `SELECT *` into a strict row schema, so a column added by a later migration made every quota read throw on an older build. Running an older build against the same plugin database, for example after a downgrade, therefore broke the pool instead of just losing the newest fields. The row schema now ignores unknown columns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he provider refuses them The pool treated every window at or above switchThreshold as exhausted. Once all accounts crossed it, the pool answered with its own 429 while the provider still accepted them; its Retry-After, "available at" time, and provider-retry.v1.availability waited for windows that were only past the threshold, so Provider Retry parked threads for hours; and the settings page and `bb pool status` called those working accounts "Exhausted". A window now counts as refused when its status is "rejected", or, when it has no status, when utilization reaches 1. Selection still prefers accounts below the threshold; when none is ready it falls back to accounts the provider still accepts, then to refused accounts with extra usage or Codex credits. The wait time, retry availability, and the exhausted status count only refused windows. Pins, affinity, the sticky cursor, family detours, and the usage recheck are unchanged whenever an account below the threshold is ready. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Accounts past the switch threshold that the provider still accepts and refused accounts with extra usage or Codex credits are one fallback group again, picked in the pool's usual order, as main picks among its extra-usage fallbacks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…reshold A pinned conversation moved to another account as soon as its own crossed switchThreshold and an account below it was ready. It now stays on its account until the provider refuses it; a conversation inheriting its parent's pin follows the same rule. New conversations still go to accounts below the threshold first, and conversations pinned to a refused account running on extra usage or Codex credits still return when an account below the threshold is ready. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With every account past the switch threshold, the pool could keep routing new and pinned conversations to a refused account running on extra usage or Codex credits while another account still had subscription quota. Accounts past the threshold that the provider still accepts now come before those paid accounts, and conversations pinned to a paid account move to one when it is ready. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 2, 2026
## Human comments
## What was wrong
After a server restart, the GitHub PR Status plugin restores each
environment's PR from its database and serves it right away. It also
starts a background re-check right away, often before the host daemon
has reconnected. That re-check returned `unavailable` ("machine isn't
available"), and `store.load` replaced the environment's known PR link
with that result. The sidebar row badge disappeared and stayed gone
until something re-read that row, such as opening the thread or
refocusing the page. Observed on prod: the server restarted at 13:04:14
and the daemon reconnected at 13:04:20. Afterwards the sidebar showed
only #6849 (the thread that was opened). Six other inbox threads with
open PRs (#6760, #6755, #6736, #6728, #6727, #6734) showed no badge,
although their links and snapshots were still in the plugin database.
## What changed
- `plugins/github-pr-status/store.ts`: when a re-check of a known PR URL
comes back `unavailable`, the environment's link is no longer replaced,
so the last snapshot keeps being served. The snapshot's `fetchedAt` is
still bumped, so the regular poll retries it. Discovery reads (no known
URL) behave as before.
- Behaviour change: `bb pull-request show` for an environment whose
machine is offline now prints the last PR bb saw, or `unavailable` when
it has none. Actions (`ready`/`draft`/`merge`) still refuse with the
machine message. The skill doc and README are updated.
## How you verified
- New store test, "keeps serving a restored PR when its machine is
unreachable after a restart": it restores a persisted PR, makes the
first re-check return `unavailable`, and checks that the PR is still
served, nothing is published, and the next successful check publishes
the update. It fails without the fix (`expected { outcome: 'unavailable'
} to deeply equal { outcome: 'available' }`) and passes with it.
- `pnpm exec turbo run test typecheck lint
--filter=bb-plugin-bb--github-pr-status`: 183/183 tests pass, typecheck
and lint clean.
> AGENT GENERATED
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/6169-account-pooler-when-every-account-is-past-s-thr_cxiiebtxyd
branch
November 2, 2026 21:55
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Human comments
What was wrong
quota.tshad a single window predicate,activeWindow(), that treated a window as blocking when its status wasrejectedor its utilization was at or aboveswitchThreshold. Every caller used it: selection inhub.ts, the pool's own 429 (Retry-Afterand the "expected to be available at" text),provider-retry.v1.availability, andaccountStatus(). So the threshold acted as a hard cutoff. Once every account crossed 98%, the pool returned its own 429 even though the provider still accepted those accounts. The wait time came from the latest past-threshold window, often a 7-day window, so Provider Retry parked threads for days. Settings andbb pool statusalso called those working accounts "Exhausted" (#6169). Separately,quotaRowSchemawas.strict(), so after a downgrade, any column added by a newer build made every quota read throw.What changed
src/quota.ts: Window logic is split into two predicates. A window is refused when its status isrejected. When the window has no status, it is refused once utilization reaches 1. A window is past threshold when it is refused or its utilization is at or aboveswitchThreshold.isQuotaExhausted(quota, family | null, now)means refused (or usage-restricted).isPastThreshold(quota, family | null, threshold, now)keeps the old threshold meaning.blockingResetAtandaccountStatusno longer take a threshold and count only refused windows.isSharedQuotaExhaustedis gone; callers usefamily = nullinstead.src/hub.tsselect(): New conversations work as on main, except that the "below threshold if any is ready" filter now usesisPastThreshold. Behind it, accounts past the threshold that the provider has not refused come next, then refused accounts with extra usage or credits (main's only fallback). Within each group the pool keeps its usual order. The cursor and round-robin order are unchanged.refreshExhaustedUsagenow selects accounts withisPastThreshold).accountAvailability()(429 text,Retry-After, andprovider-retry.v1.availability) counts only refused windows.app.tsx/src/cli.ts: "Exhausted" now means only that the provider refused the account. Its reset label uses refused windows. The threshold description, the quota detail line ("other accounts preferred from N%"), and CLI help now describe the threshold as a preference.skills/account-pool/references/accounts-and-routing.md,PLUGIN_OVERVIEW.md(3,993 of 4,000 characters), anddocs/configuration.md(switchThreshold).src/store.ts: Cherry-picked 6bd890b865:quotaRowSchemano longer uses.strict(). I dropped that commit'sfamily_overage_until_jsoncolumn because main does not have it.tierfield, and the settings banner.Behaviour choice beyond the issue (conservative): When no account below the threshold is ready, accounts the provider still accepts come before refused accounts on extra usage or Codex credits. Without this, the sticky cursor or a pin could keep spending extra usage while another account still had subscription quota. Covered by
prefers an account past the threshold that the provider accepts over extra usage.Note: As on main, the usage recheck (at most once per 30 s per account) runs whenever selection lands on an account past the threshold. That now includes the new fallback and pinned conversations staying on a past-threshold account, not only extra usage.
How you verified
New tests. Each fails on main's
quota.ts/hub.ts/app.tsxand passes with the fix:sends new conversations to accounts past the switch threshold behind those below it until the provider refuses them: two accounts at 99% and 100%allowedkeep serving (main:expected 429 to be 200). A refused account fails over to the past-threshold one, and a new below-threshold account still wins.waits only for windows the provider refused before retrying: one account is refused through a status-less 5h window at utilization 1, the other through arejected5h window. Both also have 7d windows at 0.99allowed.Retry-Afteris 3600, the message shows that time, andprovider-retry.v1.availabilityreportsretryAt = now + 1h(main:'432000', i.e. 5 days).keeps a conversation on its account past the switch threshold until the provider refuses it: a pinned session stays on its 99% account while a new session goes to the account below the threshold. Once the provider refuses the pinned account, the session moves. This fails on main and on this PR's first commit, which kept main's pin rule.prefers an account past the threshold that the provider accepts over extra usage: a new conversation and a conversation pinned to the paid account both go to the 99% account the provider still accepts. Without the ordering, both stay on the paid account.reports an account past the switch threshold as exhausted only once the provider refuses it:bb pool status --json(main:expected 'exhausted' to be 'ready').app.test.tsxdates an exhausted account by its refused window, not one past the threshold: the settings label shows the refused 5h reset, not the 7d reset.store.test.ts(cherry-picked): quota reads and writes succeed with an unknown extra column.pnpm exec turbo run typecheck lint test --filter=bb-plugin-account-pool: 10/10 tasks pass, 372 tests. The 2 lint warnings were already on main.Fixes #6169
🤖 Generated with Claude Code