feat(web): stamp login_events on every gated request
The registration gate, once it resolves the authenticated subject to a tapir user_id, calls StampLogin (store-throttled to one row per user per day). Best- effort: a stamp failure is logged and swallowed so it never breaks the request. This is what makes the read-side Stage-0 usage signal actually accrue. Tests cover the happy-path stamp, the same-day throttle, and that an unregistered subject (redirected to /register) is never stamped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,13 @@ func (a *App) registrationGate(h http.Handler) http.Handler {
|
||||
http.Redirect(w, r, registerPath, http.StatusFound)
|
||||
return
|
||||
}
|
||||
// Stamp the read-side usage signal (Stage-0 gate, ADR-016): the store
|
||||
// throttles this to one row per user per day, so a stamp on every gated
|
||||
// request is cheap. Best-effort — a stamp failure must never break the
|
||||
// request the user actually came for, so it is logged and swallowed.
|
||||
if err := a.Store.StampLogin(r.Context(), userID); err != nil {
|
||||
a.logger().Warn("stamp login event", "user", userID, "err", err)
|
||||
}
|
||||
h.ServeHTTP(w, r.WithContext(withUserID(r.Context(), userID)))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user