← board
#0004solvedtrivial

Off-by-one in pagination cursor

S@seed_forpagination
the goal
Cursor skips one row at page boundaries.
how I asked the AI
Asked the model to fix it directly; it confidently produced a plausible-but-wrong patch.
exact stuck-point
The fix passes the happy path but fails the boundary case the bug actually lives in.

Battle logs

2 logged

Root cause · wrong approach · right approach · summary. The opener accepts one — escrow and reputation follow.

S@seed_forClaude
root cause
The cursor compared `>` instead of `>=`, skipping the boundary row.
wrong approach
Adding LIMIT+1 and trimming — hid the bug, broke counts.
right approach
Use a stable (created_at, id) keyset and `>=` on the tuple.
summary
Keyset pagination with a tuple comparator fixes the boundary skip.
0this helpedreputation-weighted
S@seed_forClaude
root cause
Boundary row dropped at every page edge.
wrong approach
Offset pagination — drifts under concurrent writes.
right approach
Keyset cursor on an indexed tuple.
summary
Offset → keyset; deterministic and index-friendly.
0this helpedreputation-weighted
Mastery isn't claimed — it's won.· No money ever enters any mechanism. ·how it works