Skip to content

[STALE: REBASE FROM NEW FORK] fix(gateway): enforce Anthropic send ceilings and gate quota regressions - #43

Open
vadymhimself wants to merge 1 commit into
release/2.65.0-vadymhimself.15from
test/gateway-quota-guardrails
Open

vadymhimself wants to merge 1 commit into
release/2.65.0-vadymhimself.15from
test/gateway-quota-guardrails

Conversation

@vadymhimself

Copy link
Copy Markdown
Collaborator

Summary

  • Fork-only quota safety change targeting the hosted release line. Reproduced on .27 (d0f166aca5): an explicit one-send Anthropic OAuth budget dispatched 3 mocked inference requests on both extra-usage HTTP 400 and HTTP 429; a zero-send budget still dispatched once.
  • Reserve each Anthropic OAuth physical send at the shared oauthDispatch boundary, including continuation and image/search sidecar paths. Reuse the existing adapter budget view/pending permit, omit duplicate helper charges, and check remaining allowance before replacing the preceding refusal. No new credential store or live provider calls.
  • Preserve the fork's intentional default account walk. Only the factory default policy is expanded; custom/inherited request policies retain their exact ceilings. transientRetryOn5xx remains scoped to the existing supported key adapters; this PR does not add an Anthropic OAuth setting.
  • Add offline physical-send ceiling, inherited-use, funded-replacement, continuation and sidecar regressions; a volatile-tail/stable-cache-prefix control; and a pinned extra-usage refusal case. Direct-handler terminal fixtures now acquire their existing spend-ledger lease so metering can run.
  • Add bun run test:gateway-quota, reusing 11 existing regression files, as a step in the existing gates CI job. The required aggregate ci and fork release's exact-SHA successful push-CI requirement already exist; no permissions, branch rules, publish capability, workflow triggers or action pins change.

Verification

Pinned Bun 1.4.4, isolated HOME and OPENCODEX_HOME, synthetic provider traffic only. Original dirty worktree and running laptop/hosted gateways are untouched. Local loopback HTTP and real child gateway process exercise are included in agentradar-account-pin-e2e.test.ts; the quota tests use the real Responses handler and count actual mock inference dispatches.

  • RED on release source: 3 new tests fail with observed physical calls 3 / 3 / 1 instead of ceilings 1 / 1 / 0 for quota-400, quota-429 and zero-budget cases.
  • Final committed bun run test:gateway-quota: 213 pass, 0 fail across 11 files. Covers the budget cases, refusal preservation, exact-once funded replacement, existing default pool walking, pin/helper isolation, cache prefix stability and per-account usage.
  • bun run typecheck, bun run structure:check, bun run privacy:scan, git diff --check: pass.
  • bun test tests/responses/responses-core-modules.test.ts tests/ci-workflows/file-size-ratchet.test.ts tests/ci-workflows/ci-workflows.test.ts tests/ci-workflows/release-pipeline-contract.test.ts: 167 pass, 0 fail before the terminal-fixture-only follow-up. bun test tests/server/terminal-guard-server.test.ts: 16 pass after its lease fix, also included in the final gateway gate.
  • Final exact-commit bun scripts/test.ts --changed=v2.65.0-vadymhimself.27: 19,011 pass, 8 skip, 12 fail across 896 files. This is not a green full-suite claim. The initial run exposed 2 direct-handler terminal fixtures missing spend ownership; fixed. All 12 remaining failure names also appear in a pristine .27 control (8,060 pass, 3 skip, 12 fail across 295 selected files), not a paired full-suite proof:
    • tests/cli/cli-connect-readiness.test.ts: rejected preferred runtime lacks 2 expected model probes.
    • tests/codex-integration/native-codex-toggle.test.ts: off/on round-trip reports absent instead of current.
    • tests/server/server-auth.test.ts: connection error spells ECONNREFUSED instead of ConnectionRefused.
    • tests/service/service-claim.test.ts: sandbox service paths do not all belong to the temporary home.
    • tests/service/service-sqlite-home.test.ts: 3 home-binding assertions.
    • tests/service/service-wsl-home-ownership.test.ts: 3 home-ownership assertions.
    • tests/service/service.test.ts: 2 stale service-path assertions.
  • Workflow/security review: added only a literal local test command to the existing secret-free, read-only PR CI job. No pull_request_target, write token, egress credential, dynamic shell interpolation or new third-party action. The physical dispatch reuses the existing reservation ledger and its durable ownership checks; no log/response fields or tenant authorization changes.

The workflow itself has not yet passed on GitHub for this commit. No release tag, merge or deployment is performed by this PR.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

🤖 Generated with Claude Code

… regressions

Reserve Anthropic OAuth inference at the existing physical dispatch boundary. Share inherited request ledgers and pending-hop permits instead of bypassing ceilings or double charging helper reports. Preserve the fork default pool walk without widening custom policies.

Add hard zero/one-send, funded replacement, inherited budget, continuation and image-sidecar regression cases, stable cache-prefix control and pinned quota-400 isolation. Correct direct-handler terminal fixtures to own the spend ledger. Run the offline gateway suite inside the existing required CI gates job; fork publication retains its exact-SHA push-CI requirement.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@vadymhimself vadymhimself changed the title fix(gateway): enforce Anthropic send ceilings and gate quota regressions [STALE: REBASE FROM NEW FORK] fix(gateway): enforce Anthropic send ceilings and gate quota regressions Nov 18, 2026
@vadymhimself

Copy link
Copy Markdown
Collaborator Author

This PR is based on the superseded 2.65 gateway line. Rebuild the change from port/ar-on-upstream-2026-11-18 (upstream-derived 2.100 AR overlay, PR #46): #46 . Do not rebase onto or merge the old release line. Preserve the new gateway quota/cache gate and re-run the affected regressions. The candidate is not deployed; do not publish or replace a running gateway without explicit approval.

This branch has not been deployed

No deployments
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