Files
heidi/app/api/check
CatoandClaude Opus 5 0a9c1cd43f fix(limits): every public endpoint ran with no rate limit (#16)
Found by being asked which shared packages Heidi actually uses. It uses
ai-kit and threadkit. It was not using limitkit, and the reason is the
one SHARED.md predicts: I did not grep the registry before building.

That was not a style miss. Three endpoints were reachable by anyone
with curl and none had a ceiling:

  /api/chat         spends from a free-tier AI budget shared with every
                    other visitor
  /api/model/check  makes a real outbound call with whatever key it is
                    handed — the one endpoint here that could be used
                    to test stolen credentials in bulk
  /api/check        pure and local, but still a way to occupy the box

limitkit ships the algorithm and the HTTP edges and deliberately NO
limit values, because how many a route allows is app semantics. So the
numbers live in lib/domain/limits.ts with the reason each one is what
it is — a limit with no stated reason is one that gets "temporarily"
raised.

  chat          30 / 5 min — generous: a real conversation is a dozen
                turns, and someone working through a long WhatsApp
                thread must never meet this
  model-check    6 / 5 min — nobody legitimately needs more than a few
                attempts to paste a key correctly
  dialect-check 120 / 1 min — free to run; only about not letting one
                client monopolise the box

Verified against a running server: six probes pass, the seventh gets
429 with Retry-After and X-RateLimit-*, and the same address still has
its full dialect-check allowance — budgets are per endpoint, so
spending one cannot lock someone out of another.

Stated plainly in the module: this reads forwarded headers, so it is a
rate limit and not a security boundary. It exists to stop accidental
and casual abuse from spending a budget that belongs to everybody.

pnpm-workspace.yaml gains an allowBuilds entry — limitkit is a git
dependency and pnpm 11 silently installs NOTHING without it, so the
install "succeeds" and the package is simply absent.

145 tests.


Claude-Session: https://claude.ai/code/session_01FzYBD3sZroCAYeRgTYrpfT

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 09:17:11 -07:00
..