Page 4 of 8~245 min topic

Rate limiting lab

Inject a controlled rate limiting failure

Executable checks prove tenant RPM soft=60 hard=100; global 5k RPM; 429 includes Retry-After on fixtures — including the known misshape behind RL-FAILOPEN-61.

~35 min this pageValidation

1Learn the idea

Read

Schema and policy checks

Add executable validation at the trust boundaries of layered token-bucket limiter for multi-tenant RAG API. Reject unknown fields where they matter, bound string sizes, and coerce only after auth/signature checks when raw bytes are security-relevant. Invariant under test: tenant RPM soft=60 hard=100; global 5k RPM; 429 includes Retry-After. A TypeScript type or Python annotation is not runtime validation — pair them with parsers.

Read

Golden and adversarial fixtures

Automate the fixtures from setup, including a recreation of RL-FAILOPEN-61. Assert both the visible error and the absence of side effects (no provider call, no queue write, no flag flip). Where metrics matter, assert label enums stay bounded.

Read

Implementation artifact

assert response.headers["Retry-After"] == "2"
assert response.status_code == 429

Read

Gate semantics

Document which failures are client mistakes (4xx) versus operator/config mistakes (5xx/503). Oracle still stands: StormCo at 200 RPM gets 429 after burst; Globex at 40 RPM unaffected. Validation should make accidental “success with empty body” impossible for platform SRE stopping noisy neighbor tenant StormCo.

Read

Stage depth

Property ideas: shuffled field order, Unicode edges, maximum-length strings, and replayed timestamps. Where money, identity, or citations matter, assertion messages should cite the field name. Do not snapshot entire provider payloads in tests; assert semantically. If validation fails open “to keep the demo working,” you have inverted the lab. Tie at least one CI job to the RL-FAILOPEN-61 fixture so main cannot regress silently. Re-read tenant RPM soft=60 hard=100; global 5k RPM; 429 includes Retry-After after each new parser — convenience helpers love to bypass it.

Read

Field notes for `rate-limiting-lab` / `validation`

Table-drive status codes and error codes so reviewers see coverage at a glance. Include a Unicode normalization case if user text is accepted. Verify that oversized bodies fail before CPU-heavy work. Where digests or versions are pinned, assert mismatch behavior. Keep golden files small enough to read in review. CI should fail on skipped tests that mark the incident fixture as xfail without a ticket link. In this chapter the product is layered token-bucket limiter for multi-tenant RAG API, the human stakeholder is platform SRE stopping noisy neighbor tenant StormCo, and the incident id you design against is RL-FAILOPEN-61. Re-state the oracle in your notes — StormCo at 200 RPM gets 429 after burst; Globex at 40 RPM unaffected — and keep the invariant visible: tenant RPM soft=60 hard=100; global 5k RPM; 429 includes Retry-After. Track 429_ratio_by_tenant and provider_429_ratio ≤ 0.01 as the scoreboard. Surface under change control: POST /v1/rag/answer. If you only have forty minutes, finish the fixture for Redis down → fail-open floods provider → shared 429s before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.

Go deeper

Before you start

Why this matters

List three fixtures: one golden success, one schema/auth reject, and one regression for RL-FAILOPEN-61. For each, write the exact assertion (status, code, metric, or citation) that must turn red if broken.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Do parsers run before side effects?
2. Is RL-FAILOPEN-61 represented as a fixture?
3. Are side-effect absences asserted?

All responses are required.