BuildMidBackendAuto-graded
Fix pagination that loses records between pages
Walking every page of /records returns fewer rows than the dataset holds. Make each record come back exactly once, in order.The/records endpoint returns a dataset ordered by created_at, then id, one page at a time. Clients that follow next_cursor from the first page to the last get back fewer records than the dataset holds, and which ones are missing changes with the page size. Nothing errors. Fix page() so a full walk returns every record exactly once, in order, with no page larger than limit. It has to work on any data in that order (ids need not follow created_at order), when a client changes limit between calls, and when records are added while a client is walking.30 min
Python
Goals
- A full walk returns exactly the dataset, in order, with no record skipped or repeated.
- It works on any data sorted by
(created_at, id), not only this sample: ids are unique but need not followcreated_atorder, and no page is ever larger thanlimit. - A client may change
limitbetween calls: the next page still starts right after the last record it got. - A record added while a client is walking never makes it skip or repeat a record: one added behind its position is not returned, one added ahead of it shows up in order.
What it measures
Cursor designHow the cursor lets a client pick up exactly where the previous page stopped.
Reasoning about orderWorking out what each page boundary has to guarantee for the sort order in use.
Checking completenessNoticing records that go missing without an error, and checking a full walk against the source.
Your environment
Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish
Start this lab
30 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo