cloud-vault/document: add keyset cursor-based pagination#375
Draft
biglyan wants to merge 2 commits into
Draft
Conversation
Adds an AfterID cursor field to ListQuery and a NextCursor/HasMore pair to ListResult, enabling clients to page through documents without the performance degradation of large OFFSET values. Usage: include after_id=<id> in the query string, using the previous response's next_cursor value. Offset-based pagination continues to work unchanged. The repository skips the COUNT query in cursor mode. The secondary id sort in ORDER BY makes cursor ordering stable when the primary sort column ties. https://claude.ai/code/session_014xk5ygPiuUm2JNZMbFjHNy
Code Coverage Report ✅Total coverage: 74.1% (gate: ≥70%) 15 packages with lowest coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds cursor-based (keyset) pagination to the document list endpoint as a complement to the existing offset-based pagination — the last strongly-recommended item from the cloud-vault feature-completeness review.
ListQuery.AfterID: pass thenext_cursorvalue from a previous response to page forward without offset scanning cost.ListResult.NextCursor/HasMore: populated when more pages exist; empty/false on the last page.ORDER BYclauses gain a secondary, id <dir>sort so the cursor position is unambiguous when the primary sort column ties.COUNT(*)query and uses keysetWHEREconditions (noOFFSETscan). Offset-based pagination is unchanged and still works.AfterIDis optional; existing callers that uselimit/offsetsee no change in behavior.API
Response adds two new fields:
{ "data": { "items": [...], "total": -1, "limit": 50, "offset": 0, "next_cursor": "<last-item-id>", "has_more": true } }Test plan
TestSQLiteRepository_List_KeysetCursor: 5 docs, 3 cursor-based pages, no overlap, full coverageTestBuildOrderClause_*: updated to expect secondaryidsortgo test ./internal/document/...)https://claude.ai/code/session_014xk5ygPiuUm2JNZMbFjHNy
Generated by Claude Code