Context
paginate in src/pagination.ts builds a fresh { limit } query on every loop iteration and never reads cursor metadata, so when a page contains at least limit items the same first page is requested repeatedly and yielded more than once. The sibling helpers parseCursorPage and buildPaginationQuery defined in the same file are never called by paginate. tests/pagination-helper.test.ts currently encodes the duplicate behavior: paginate(fetchPage, { limit: 2, maxPages: 3 }) against a fetch that always returns [1, 2] asserts 6 yielded items.
Proposed Change
Rework paginate to be cursor-driven: accept a fetch that returns page metadata (items plus a next cursor, matching the existing CursorPage<T> shape), feed the returned cursor back through buildPaginationQuery, and stop when the cursor is null/empty, a page is shorter than limit, or maxPages is reached.
Acceptance Criteria
Suggested Label
bug
ETA: 24 hours
Context
paginateinsrc/pagination.tsbuilds a fresh{ limit }query on every loop iteration and never reads cursor metadata, so when a page contains at leastlimititems the same first page is requested repeatedly and yielded more than once. The sibling helpersparseCursorPageandbuildPaginationQuerydefined in the same file are never called bypaginate.tests/pagination-helper.test.tscurrently encodes the duplicate behavior:paginate(fetchPage, { limit: 2, maxPages: 3 })against a fetch that always returns[1, 2]asserts 6 yielded items.Proposed Change
Rework
paginateto be cursor-driven: accept a fetch that returns page metadata (items plus a next cursor, matching the existingCursorPage<T>shape), feed the returned cursor back throughbuildPaginationQuery, and stop when the cursor is null/empty, a page is shorter thanlimit, ormaxPagesis reached.Acceptance Criteria
c1, page 2 -> null cursor) is yielded once per item, withfetchPagecalled first with no cursor and then with{ cursor: 'c1' }limitno longer triggers a repeat fetch of the same page (no duplicate items)maxPages, empty-page, and cursor-less responses are covered by updated tests intests/pagination-helper.test.tsSuggested Label
bug
ETA: 24 hours