fix(rpc): stabilize announce pagination and cap delivery trace state#18
fix(rpc): stabilize announce pagination and cap delivery trace state#18
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29a98401b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
crates/reticulum/src/rpc/daemon.rs
Outdated
| .map_err(std::io::Error::other)?; | ||
| let next_cursor = if items.len() >= limit { | ||
| items.last().map(|record| record.timestamp.to_string()) | ||
| items.last().map(|record| format!("{}:{}", record.timestamp, record.id)) |
There was a problem hiding this comment.
Make announce cursor boundary match first-page sort order
This cursor now uses timestamp:id, which assumes the page is ordered by timestamp DESC, id DESC, but the initial list_announces query path (before_ts=None) still sorts only by timestamp in MessagesStore::list_announces. When several announces share a timestamp, the first page can return IDs in a different tie order, so the next-page predicate id < last_id may duplicate items already seen or skip unseen ones. Update the no-cursor query to use the same tie-break ordering as the cursor boundary.
Useful? React with 👍 / 👎.
Summary
This PR addresses both review findings from PR #17 by fixing pagination correctness and unbounded RPC delivery-trace memory usage.
Changes
1) Stable announce pagination cursor
list_announcesused only timestamp as the page cursor (next_cursor = timestamp). Records with identical timestamps could be skipped across pages.next_cursor = "<timestamp>:<id>".(timestamp, id)pairs.ORDER BY timestamp DESC, id DESCtimestamp < ? OR (timestamp = ? AND id < ?)crates/reticulum/src/rpc/daemon.rscrates/reticulum/src/storage/messages.rs2) Cap delivery trace state growth
delivery_traceskept an entry per unique message ID forever; only per-message transitions were capped, causing unbounded growth.Validation
29a9840codex/pr17-review-fixesNotes
mainand keeps existing API shape intact while improving cursor behavior and long-run memory safety.