Skip to content

fix(core): quota-driven quota-skip re-admission + per-model reactive skip scoping (#1974, #1976) - #1978

Merged
dezren39 merged 1 commit into
mainfrom
fix/quota-gate-readmission-1974-1976
Nov 8, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/quota-gate-readmission-1974-1976

Conversation

@dezren39

@dezren39 dezren39 commented Nov 8, 2026 •

Copy link
Copy Markdown

Refs #1974, Refs #1976 — stacked on queue/gate-fix-1974 (PR #1975); retarget to main once #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 manual route_note removes 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 in completed()/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:

  • The quota source is the fleet's real one — the quota gatherer's snapshot quota-current.json (pm-aggregator gatherer, code#1151), rewritten every ~15 minutes from the providers' own quota endpoints. packages/core/src/quota-current.ts reads 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's ModelPlan.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.
  • The wiring — refreshQuotaSkips in model-resolver.ts runs beside refreshQuotaGate on the same per-provider feed cadence (shouldFeedQuota TTL) at every resolution, and calls ModelRoute.releaseQuotaSkipsForCurrent per due target.
  • The judgement — releaseQuotaSkipsForSnapshot / releaseQuotaSkipsForCurrent in model-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 same QuotaSnapshot.known/isKnownFull contract 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 (observeProviderQuota not-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>, match provider/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 standard poolQuotaExhausted applies (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.
  • Consumers updated for the new shape: 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).
  • Decision detail: learned quota skips now report quota-skip; user-skip means only the operator's own route-overrides.json override.
  • One pre-existing router: auto-disable providers at 100% quota until a fresh read shows headroom (cline-pass, commandcode, go) #984 test updated to the new record shape (same hold, same lapse).

Not in this PR (stated plainly): #1976's credential-restore layer — per-target benches restored from route_health can 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

Commits

@dezren39 dezren39 changed the title fix(core): quota-skip probe re-admission + per-model reactive skip scoping (#1974, #1976) fix(core): quota-driven quota-skip re-admission + per-model reactive skip scoping (#1974, #1976) Nov 8, 2026
@dezren39
dezren39 changed the base branch from queue/gate-fix-1974 to main November 8, 2026 06:18
…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
dezren39 force-pushed the fix/quota-gate-readmission-1974-1976 branch from 4879e5c to c82ab6d Compare November 8, 2026 06:24
@dezren39

dezren39 commented Nov 8, 2026

Copy link
Copy Markdown
Author

Rebased onto main after the pool-verdict abolition (#1979) landed, and merged. The two original commits replayed as one (c82ab6d730); the rebase reconciliation, stated plainly:

Refs #1974, Refs #1976 — the remaining open part of #1976 (per-target benches restored from route_health carrying a sibling family's reset on a shared credential) is unchanged and still needs its own design. Deploy (pin bump + laptop switch) follows in the same lane.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant