Skip to content

Limit each visitor to 10 messages a day - #61

Open
TechNomadCode wants to merge 2 commits into
mainfrom
feat/rate-limit
Open

TechNomadCode wants to merge 2 commits into
mainfrom
feat/rate-limit

Conversation

@TechNomadCode

Copy link
Copy Markdown
Owner

Slice 8: each visitor may send 10 messages to the real model per UTC day; the 11th gets a 429 and a notice saying when they can carry on.

  • Counts live in message_counts, keyed by an HMAC of the visitor's IP address (IPv6 by its /64) and the day. No address is stored. Only the secret key reaches them, through take_message, which refuses without counting and deletes earlier days' rows.
  • Only messages to the real model count; the fakes and replays count nothing.
  • Needs SUPABASE_SECRET_KEY in the Vercel project (README, step 3), or the chat refuses every message.

src/server files changed: rate-limit.ts (new, the limit), env.ts (the limit's setting), db/clients.ts (comment), db/database.types.ts (generated). src/lib/chat.ts only gains the limit's size and refusal text. Nothing the model receives changed.

Checks (local): verify (615 unit tests and the build), verify:db, test:e2e (93), verify:secrets.

TechNomadCode and others added 2 commits October 26, 2026 16:02
Count each visitor's messages to the real model in message_counts, keyed
by an HMAC of the IP address (an IPv6 address by its /64) and the UTC
day, so no address is stored. Only the secret key reaches the counts,
through take_message, which refuses the 11th message without counting
it and deletes earlier days' rows. The chat route answers a refused
message with a 429, and the page shows when the visitor can carry on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The browser's intro timed its arrivals from the first paint, 15-20ms
after the server's page began them, so a swap early in the fade stepped
the heading back, which failed the intro's arrival test in CI. It now
reads the server's start while it first renders, before React removes
the server's intro.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant