Code Room
Vibe codingMediumvc-g239
Subject Ai code reviewLevel Mid–Senior~15 minCommon in Algorithms & data structures interviewsIndustries Technology, Software development

Question

An AI agent added rate limiting to a Go API gateway, claiming it 'allows up to N requests per sliding minute per client':

go
func (l *Limiter) Allow(clientID string) bool {    now := time.Now()    l.mu.Lock()    defer l.mu.Unlock()    times := l.hits[clientID]    cutoff := now.Add(-time.Minute)    var kept []time.Time    for _, t := range times {        if t.After(cutoff) {            kept = append(kept, t)        }    }    kept = append(kept, now)    l.hits[clientID] = kept    return len(kept) <= l.limit}

It passed a test that fires N requests and expects the (N+1)th to be blocked. What do you verify, and what's the real defect?

What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.