SIGN IN SIGN UP

Record keyless client IPs for zero-credit operations

The keyless usage log is the only place a keyless caller's IP is
persisted — requests.team_id collapses all keyless traffic onto one
preview team. logKeylessCreditUsage early-returned whenever credits
were <= 0, and the research proxy only called chargeKeylessCredits
inside its `credits > 0` branch. The Research Index paper endpoints
(research_paper_search, paper_inspect, paper_read, related_papers) all
cost 0 credits, so none of that traffic left an IP anywhere: during a
distributed corpus-harvest incident only 3.0% of the requests had a
resolvable IP.

Write the usage row regardless of credit cost, and record it on every
research outcome rather than only billable successes — ID enumeration
mostly produces upstream misses. Billing is untouched: the per-IP
Redis credit counter is still only incremented for positive credits,
paper endpoints still cost 0, and `credits` is still 0 on every
non-2xx path. A credits_used = 0 row cannot move any credit total; it
only makes the request countable.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0167vSfEGsVL3S7DiBERewNc
C
Claude committed
06506155cf053d84c419bf1060e4ee8bcedd059d
Parent: 1c522c1
Committed by Karan Lokchandani <karanlokchandani@protonmail.com> on 8/20/2026, 8:33:07 AM