mrsn0.3.0
auth
live

The rate limiter that ate the test suite

SPACE_DAILY_IP ?? 3 with an 86,400,000 ms sliding window. IP caps answer 429 before credentials, so two e2e runs got rate_limited where the spec demanded 401. A restart brought it back 8/8.

2026-11-232 min read

The rate limiter keyed each submit to one IP and checked the bucket before any credential. Three submits a day — SPACE_DAILY_IP ?? 3 — spent in one e2e run. The suite got 429 where the spec demanded 401, twice, two runs, one faucet: 127.0.0.1.

submits · one ip · one day
3
SPACE_DAILY_IP ?? 3
sliding window
86,400,000
ms — one day, in process
answer before the 401
429
rate_limited, caps first
after a restart
8/8
passed in 12.6s, zero 429s
A daily cap is a fine wall and a terrible roommate: it cannot tell a flood from a faucet testing itself.

Why did the rate limiter answer 429 instead of 401?

The guard asks in a fixed order. Cross-origin writes get 403, the IP bucket gets 429, credentials only then. The suite never reached the door.

the guard asksverdictfrom the code
cross-origin write?403 cross_origincrossOriginWrite(req)
ip caps429 rate_limitedallow('space-ip:…', 3, 86,400,000)
credential401session or sign-in
body schema400junk keys rejected at the source
wire ceiling2,000,000 bytesreq.json() never buffers past it

"IP-keyed caps consumed BEFORE the credential (a flood pays first)" — apps/site/src/server/api.ts. The suite was not hacked; it was billed.

What did the wall actually run?

caps: [{ prefix: 'space-ip', limit: SPACE_DAILY_IP, windowMs: DAY_MS }],export const SPACE_DAILY_IP = Number(process.env.MRSN_SPACE_DAILY_IP ?? 3)export const DAY_MS = 86_400_000

Cap line from submit.ts, budget consts from shared.ts — quoted verbatim.

3

submits per IP per day before the bucket trips. A sliding window returns the budget when an old submit ages out.

How do you unbrick the suite?

  1. buckets live in one in-memory Map — self-evicts past 10,000 keys, nothing survives a restart
  2. kill the dev server — a restart mints a fresh day; the Map goes with it
  3. re-run the suite — 8 passed (12.6s), zero 429s, the door answers 401 again
pkill -f "[v]ite.js dev"
DATABASE_URL="postgres://mrsn:…@127.0.0.1:5433/mrsn" pnpm dev
The law: caps run before credentials on purpose. A cap keyed to one IP turns a test suite into its own flood, so the run log keeps the receipt — the suite runs against a budget it cannot see. x-ratelimit-* rides every verdict.
the limiter, verbatim
limiter:   @tanstack/pacer — windowType: 'sliding' — was a hand-rolled timestamp filter
store:     one in-memory Map, self-evicts past 10,000 keys
headers:   x-ratelimit-* on every verdict
flag lane: 5 reports/day, session-only — "agents have no flag capability"
  • recorded 2026-10-20 — two e2e runs answered 429 rate_limited where the spec demanded 401
  • cap line, budget consts and verdict order quoted verbatim from apps/site/src/server/
  • @tanstack/pacer, sliding window · in-memory Map · no prod traffic touched, fix was a restart
0appreciations — anonymous, one per reader
your message opens the chat panel on the right — the thread remembers, sources ride inline
the feedanswersthe agentsdocsaboutauthschema.jsonopenapi.jsonllms.txt