Skip to content

fix(core): let due bench probes recover quota-exhausted pools - #1473

Merged
dezren39 merged 1 commit into
mainfrom
pool-probe-recovery
Nov 8, 2026
Merged

dezren39 merged 1 commit into
mainfrom
pool-probe-recovery

Conversation

@dezren39

@dezren39 dezren39 commented Nov 3, 2026 •

Copy link
Copy Markdown

Closes #1390.

Pool quota exclusion counted every quota-out leaf toward POOL_QUOTA_LEAVES with no probe-due carve-out, so leaves whose bench probes were due after a trusted reset still exhausted the pool and the resolver excluded even the due probes, defeating the half-open recovery path for up to the escalated cooldown.

  • model-route: poolQuotaExhausted skips leaves whose bench probe is due (probeDue false while claimed/pre-reset, so those keep counting).
  • model-resolver: ready + last-resort pool exclusion admits a leaf whose own probe is due.
  • Tests: new pool-shaped regression in model-route.test.ts + resolver recovery test in model-resolver.test.ts.
  • Also removes dead retainedQuotaWindowMs (pre-existing TS6133) so bun typecheck is clean.

Verification:


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T00:50:26.124168Z aee912a PR opened
ℹ️ 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.

@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: aee912ad6f

ℹ️ 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".

Comment thread packages/core/src/model-route.ts Outdated
if (!target) continue
const credentialID = credentialOf?.(leaf)
if (!quotaOut(target, credentialID, now, location)) continue
if (probeDue(target, credentialID, now)) continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep independently quota-gated leaves in the exhaustion count

When a benched leaf learns an early reset and subsequently receives a known-full snapshot with a later reset (or acquires a balance hold), probeDue() becomes true at the earlier reset even though its independent quota gate still blocks recovery. armBenchProbe() deliberately retains the earliest reset, so this condition is possible through the existing quota observers. Unconditionally removing that leaf from the count makes a three-leaf pool with two quota-out members appear recovered, allowing the resolver to select the untried third member rather than the outside fallback, even though neither exhausted member can actually probe. Only carve out a due probe when its independent quota gate also permits admission; otherwise the pool's hard exclusion is lifted prematurely.

Useful? React with 👍 / 👎.

@dezren39

dezren39 commented Nov 5, 2026

Copy link
Copy Markdown
Author

Agent note - handed off

@dezren39
dezren39 force-pushed the pool-probe-recovery branch from aee912a to 5553005 Compare November 8, 2026 02:47
@dezren39
dezren39 force-pushed the pool-probe-recovery branch from 5553005 to 1dafe0f Compare November 8, 2026 02:52
@developing-today

Copy link
Copy Markdown

Fixed in the rebased head (1dafe0f) — thank you, the scenario is reachable exactly as described: armBenchProbe retains the earliest reset, so a benched leaf can be probe-due while an independent gate with a later reset still blocks it.

poolQuotaExhausted now carves out a due probe only when no independent quota gate blocks the leaf. The new independentQuotaGate check (model-route.ts) mirrors the gate branches of quotaEvidence: a credential quota gate, or a provider gate (known-full snapshot, balance hold, or the reactive attempt-reported skip). A gated leaf keeps counting toward the pool threshold until its gate lifts.

Regression test added in model-route.test.ts: "a due probe behind an independent quota gate still counts toward its pool (#1390, Codex PR #1473)" — benches two leaves, arms the first leaf's probe at the early reset (pool verdict lifts), then observes a fresher known-full snapshot with a later reset and asserts the still-due probe counts again and the pool is exhausted. Targeted suites: 220 pass / 0 fail; typecheck clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

queue/queued Has a queued task in the Supabase agent queue

Projects

None yet

1 participant