Repository navigation
fix(pm-stack): composite (ts, event_id) cursor for decision-events read-back (#9614) - #9645
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 52 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Fixes #9614. Task 16159 (lane code-d).
Problem
The decision-events Worker's read-back endpoint (
GET /sets/<setId>/events) paginated withafteras a bare timestamp andts > ?, while ordering by(ts, event_id). A page boundary inside a group of events sharing onetsmade the rest of that group unreachable (Codex P2 on merged PR #9341).Fix
nextAfter—<ts>|<eventId>, the(ts, event_id)pair of the page's last event (null on an empty page) — andafteraccepts that form, resuming with(ts > ? OR (ts = ? AND event_id > ?)).src/events.ts:encodeEventsCursor/parseEventsCursor), keeping it unit-testable without the CF runtime. Splitting at the first|is unambiguous because an ISO timestamp never contains one.afterwith its original meaning (strictly after that ts). A malformed cursor is a 400 instead of a silent first page.Tests (oracle: the pre-existing behaviour)
test/pagination.test.tsruns the real Worker handler and its real SQL against an in-memory SQLite database standing in for D1, seeded out of order with three events sharing onets: paging atlimit=2returns all five set events exactly once, in(ts, event_id)order. Verified failing on the original code (2 of 3 tests fail; the legacy bare-ts test passes there, as it should).test/events.test.ts(round-trip, separator-in-eventId, legacy bare ts, malformed inputs).bun test: 14 pass, 0 fail.bunx tsc --noEmit: pass. biome/prettier formatted.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.