Repository navigation
fix(core): quota-driven quota-skip re-admission + per-model reactive skip scoping (#1974, #1976) - #1978
Merged
Conversation
…skip scoping (#1974, #1976) Rebased onto main after the pool-verdict abolition (#1979): the two commits of this PR replayed as one, with the abolition kept whole. #1974: re-admission is a judgement over the gathered quota snapshot (quota-current.json, refreshed ~15min from the providers own endpoints), never a probe attempt. releaseQuotaSkipsForCurrent/ForSnapshot lift a learned attempt-reported skip only when the freshest reading for the answering model shows its window below full; the sources reset governs over the error-quoted date; no reading, no judgement. refreshQuotaSkips runs beside refreshQuotaGate at every resolution. #1976: a credential-less quota answer plants a model-scoped skip naming only the answering target; provider scope requires a second distinct target of the provider answering quota while the first hold stands (QUOTA_SKIP_CORROBORATION_SOURCES). Learned skips report quota-skip in decision detail; user-skip is the operators own override only. Rebase reconciliation: poolQuotaExhausted and its evidence machinery (quotaEvidence/staleGateEvidence/independentQuotaGate) stay deleted per the abolition — per-leg and per-provider state only, no pool facts. The one #1978 test that asserted the deleted verdict was rewritten to assert the surviving behavior (one family out stays model-scoped; two families promote to provider scope), and the abolitions per-leg test was updated for the #1976 scoping it now composes with.
dezren39
force-pushed
the
fix/quota-gate-readmission-1974-1976
branch
from
November 8, 2026 06:24
4879e5c to
c82ab6d
Compare
Author
|
Rebased onto
Refs #1974, Refs #1976 — the remaining open part of #1976 (per-target benches restored from |
This was referenced Nov 8, 2026
Merged
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.
Refs #1974, Refs #1976 — stacked on
queue/gate-fix-1974(PR #1975); retarget tomainonce #1975 lands or is reworked (its abolition rework is in flight in a parallel lane; the stacking note below stands). Drew's orders: 2026-11-07 23:03 CST — "removing the record manually doesn't fix anything. fix the code." The manualroute_noteremoves applied live that night (OpenDesign/Antigravity) are band-aids; this PR is the durable code. Not deployed — the pin-bump deploy is sequenced separately.#1974 — window-roll re-admission is QUOTA-DRIVEN (probe design withdrawn)
Drew's design correction, 2026-11-07 23:17 CST: "who needs a plan.json just look at the quota like don't send random wasted 'probe'."
The half-open probe this PR originally shipped for attempt-reported quota skips is removed, wholesale:
quotaSkipProbeDue/claimQuotaSkipProbe/releaseQuotaSkipProbe, the probe settlement incompleted()/failed(), the resolver's probe admission in the ready filter, the probe-claim spend/hand-back on picks, and the last-resort exclusion for probe-admitted leaves. No attempt is ever spent to test whether a gated door recovered.Re-admission is now a judgement over the provider's measured quota state:
quota-current.json(pm-aggregator gatherer, code#1151), rewritten every ~15 minutes from the providers' own quota endpoints.packages/core/src/quota-current.tsreads it from the aggregator state directory beside OpenCode's state root (or a copy in the state root itself). Its per-provider/per-model windows carry used percents and the source's own reset times. The old consumption point —refreshQuotaGate'sModelPlan.readStore(dataDir).plans(plans.json) — is untouched for the plan-derived gate; providers the fleet doesn't keep plans for simply have no plan feed, and are now covered by the gathered snapshot instead of by nothing.refreshQuotaSkipsinmodel-resolver.tsruns besiderefreshQuotaGateon the same per-provider feed cadence (shouldFeedQuotaTTL) at every resolution, and callsModelRoute.releaseQuotaSkipsForCurrentper due target.releaseQuotaSkipsForSnapshot/releaseQuotaSkipsForCurrentinmodel-route.ts: a learned attempt-reported skip is lifted when the freshest reading for the answering model shows its window below full. The source governs, not the error: the reading's own reset replaces the reset date the original error quoted (the OpenDesign failure shape — window rolled early, error said Nov 10, router believed it for 33h). A reading that still shows the window full lifts nothing; a stale reading is no evidence; a provider the snapshot does not carry keeps its skip — no reading, no judgement, and no probe fallback. While a corroborated provider-wide record stands, only provider-wide headroom lifts it. Readings are judged through the sameQuotaSnapshot.known/isKnownFullcontract as every other gate consumer, with the plant-time floor the proactive feed's own out-of-order guard uses (a reading older than the answer that planted the skip cannot contradict it). The plan-feed path (observeProviderQuotanot-full) releases through the same function, so both producers share one re-judgement.#1976 — family-blind scoping + label (unchanged from the original PR)
observeQuotaFailure's credential-less timed path plants a model-scoped skip (quota-model:<provider>:<model>, matchprovider/model) naming only the answering target. Provider scope requires corroboration: a second distinct target of the provider answering quota while the first family's hold stands — the same ≥2-source standardpoolQuotaExhaustedapplies (tracked in a process-local per-provider ledger; after a restart, corroboration rebuilds from live answers, the conservative direction). The balance-exhaustion path is unchanged — a provider balance grant is provider-scope evidence by nature.quotaEvidence(a model skip is per-target evidence — two families out on their own answers are two sources),independentQuotaGate,staleGateEvidence(from fix(core): pool quota verdict ignores bench evidence whose gates have all lapsed #1975's branch).quota-skip;user-skipmeans only the operator's ownroute-overrides.jsonoverride.Not in this PR (stated plainly): #1976's credential-restore layer — per-target benches restored from
route_healthcan still carry a sibling family's reset on a shared credential, because per-family quota windows on one credential aren't modelled anywhere in the gate state. That needs its own design and is the remaining open part of #1976.Tests
model-route.test.ts): headroom reading lifts the skip long before the stated reset, with the source's reset governing; a still-full reading lifts nothing (and a stale one judges nothing); a provider/model the snapshot doesn't carry keeps its skip; a corroborated provider-wide skip lifts only on provider-wide headroom; plus the kept fix(core): quota gates are credential/provider-scoped and family-blind — Antigravity Gemini (4% used) silenced by its Claude family's wall #1976 tests (model scoping, corroboration incl. lapse-of-first-hold, fresher snapshot release, per-target pool evidence).quota-current.test.ts(5 tests): the parser against the gatherer's real file shape (provider windows + per-model windows), errored/unmeasured entries carry no reading, malformed file is no readings, the state-root read locations.packages/core: typecheck clean (bun run typecheck).queue/gate-fix-1974when this PR first opened, and unchanged by the rework: fix(core): pool quota verdict ignores bench evidence whose gates have all lapsed #1975's stale-bench carve-out also lifts the pool verdict for bench-only setups whose benches were planted with no independent gate, which those tests' opening assertions rely on. That reconciliation belongs to the fix(core): pool quota verdict ignores bench evidence whose gates have all lapsed #1975 rework; this PR neither fixes nor worsens it.Commits
9021ffbca8— the original PR (probe design, now superseded in-tree).4879e5c77d— "fix(core): re-admit quota skips from the gathered quota snapshot, not a probe attempt (fix(core): quota gates never re-admit after a window roll — attempt-reported skip 'until' outlives its period (opendesign dark 33h) #1974)": probe machinery removed; quota-driven re-admission wired as above.