You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mcpx(completion): rate limiter admits before pool validation — unknown server names mint fresh limiter buckets, so the per-server window never binds bogus names and bucket growth is request-rate × window #6978
In handleComplete, the completion rate limiter is consulted before the pool lookup validates the requested server — by design, so a refused request never wakes an upstream. But the limiter keys include the requested server name, and CanonicalName passes unknown names through unchanged. So every distinct bogus server value mints fresh limiter buckets: the per-server window (completion.serverPerMinute) can never bind a name that does not exist (each name has its own budget), the per-caller window is also keyed per server spelling, and bucket growth between sweeps is bounded only by request rate × the sweep interval. The handler's own tests demonstrate the ordering: with an unknown server, an admitted request reaches the pool lookup and gets a 400 — after it has already been counted by the limiter.
On current main (fc035359245855fd5b3db1d6b85ee60223abcf20, verified via git show origin/main):
pkgs/mcpx/internal/daemon/ops.go line 378: if refused := s.completeLimiter.admit([]limitCheck{...}) with keys "caller\x00" + completionCaller(cc) + "\x00" + serverName and "server\x00" + serverName; the pool validation p, ok := s.reg.Pool(req.Server) is only at line 397, after admission.
pkgs/mcpx/internal/daemon/registry.go lines 1467–1479: CanonicalName returns nameOrNS unchanged when it matches no pool and no namespace.
pkgs/mcpx/internal/daemon/ratelimit.go line 85: admission creates l.buckets[c.Key] = &rateBucket{start: now, n: 1} per new key; expired buckets are swept at most once per minute (lines 77–84) and only on the new-bucket path.
pkgs/mcpx/internal/daemon/completion_ratelimit_test.go: TestHandleCompleteRateLimitRefusesBeforePool uses an unknown server and expects admission to precede the pool's 400 — pinning the ordering without pinning any bound on distinct-name buckets.
Why it matters
The per-server window is described in the PR as "the backstop that does not depend on caller identity" — for nonexistent servers it is no backstop at all, and a client spraying distinct bogus server names grows the limiter's in-memory map at request rate for at least a full window per name. Impact is bounded (bogus requests still 400 and never wake an upstream), but the limiter's own state should not be client-shaped: validating the server exists before admission, or not minting buckets for names the registry does not know, closes it without changing the refusal-before-pool guarantee for real servers.
Acceptance criteria
Requests naming a server/namespace the registry does not know do not create limiter buckets (e.g. existence is checked before admission, while refusal for known servers still happens before any pool lease is acquired).
A handler test pins it: repeated /v1/complete calls with distinct unknown server names leave the limiter's bucket count bounded (or are refused without admission).
Existing completion rate-limit tests still pass, including refusal-before-pool for a known server and the canonical-spelling sharing test.
Task: task 11362 handed off to the opencode claimant per execution-lane assignment (checkpoint stage handed_off). The claimant's bound opencode session drives this task to its terminal state.
Shipped:Registry.KnownServer (map reads only) gates completion-limiter admission in handleComplete — unknown server names take the pool lookup's 400 without minting limiter buckets; known servers keep refusal-before-pool.
Verified:go test ./internal/daemon/ -run Complete — all 6 tests pass incl. new TestHandleCompleteUnknownServersMintNoLimiterBuckets (20 distinct unknown names, bucket count stays 0); full daemon package go test -count=1 ok (169.8s); Codex clean at PR head 816a236.
Activity
developing-today commentedon Nov 7, 2026
CODE-2214
dezren39 commentedon Nov 8, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 9, 2026
agent-note:v1 lane=code-b task=11362 stage=handed_off — Issue #6978 revalidated fresh: OPEN, no hard-stop labels. Task 11362 (triage) opencode-assigned (lane row 3656); handing off to opencode claimant, parking 1200s.
🤖 Agent note · handed off
15 remaining items
dezren39 commentedon Nov 11, 2026
🤖 Agent note · picked up direct (lane code-b)
small_fix— mcpx completion limiter must not mint buckets for unknown server names.handleComplete(ops.go) admits throughcompleteLimiterkeyed byCanonicalName(req.Server), which returns unknown names unchanged, so every distinct bogus name mints two fresh buckets before the pool lookup rejects it.fix(mcpx): completion limiter mints no buckets for unknown servers (#…
dezren39 commentedon Nov 11, 2026
🤖 Agent note · done (lane code-b)
Registry.KnownServer(map reads only) gates completion-limiter admission inhandleComplete— unknown server names take the pool lookup's 400 without minting limiter buckets; known servers keep refusal-before-pool.go test ./internal/daemon/ -run Complete— all 6 tests pass incl. newTestHandleCompleteUnknownServersMintNoLimiterBuckets(20 distinct unknown names, bucket count stays 0); full daemon packagego test -count=1ok (169.8s); Codex clean at PR head 816a236.