feat(mcp): log initialize refusals, and say which bucket refused #22
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-limiter-warn"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs #20, step 1 of the order. A gate, not a step: it ships and gets provoked on beta before any of the rest, because the whole diagnosis rests on inference from a logged absence and a good chain is not an observation.
What was missing
Nobody has directly observed this branch being taken. A user hitting the limit produced no server-side evidence at all: auth succeeded, no tool call followed, and the gap between them was the entire diagnosis. That gap is why the cause took an afternoon to find, and why the conclusion drawn from it — that the window "needs real time to reset" — was wrong in the direction that guarantees a second failure after the wait.
Two halves
The warn line.
user_hashis the domain-separated identity hash, never the subject or the token.burstandrefill_secondsare logged so the line carries the rule it enforced rather than making a reader go and find it.And it names which bucket refused, because a refusal that says only "refused" is the same object as the 429 that says only "later". Three diagnoses were one value:
bearersubjectbucket_capacityMAX_BUCKETS_PER_MAP— not a quota refusal at all, and indistinguishable from one until nowsubjectis the shape a client minting a fresh token per session makes: every attempt gets a new bearer bucket and the same subject bucket, so the subject bucket is what runs out. That is #21, and it is almost certainly what happened here. Without the scope, the log line would have been unable to tell the two apart, which would have repeated the original fault one layer in.No behaviour change
Same requests refused, same status, same body.
Retry-After, a distinguishable error code, the env vars and the status counter are the rest of #20 and are deliberately absent here.Verified by mutation
Bearera_refusal_names_the_subject_bucket, aloneSubjecta_refusal_names_the_bearer_bucket, aloneSubjectlogs the string"bearer"refusal_scopes_have_distinct_log_values, aloneEach with the pattern asserted to apply and the harness checked for a
test result:line.What is not tested here, stated rather than papered over: that the warn line itself fires. That needs a tracing subscriber capture, and the verification Alan sequenced is better than a test would be — provoke it on
caldav-mcp-beta, which has logged two lines since08:21:50Z, both startup. A 429 against that background is unmissable. A test would prove the code path; beta proves the deployed artefact.Gates
cargo fmt --check,cargo clippy -D warnings,cargo test --all-features(113 + 9),cargo audit,cargo deny check bans licenses sources— green onrustc 1.98.0, through the shared build slot.