Repository navigation
Conversation
Each resume or reconnect re-downloaded the whole own-author kind 30078 read-state snapshot. The relay now accepts an optional received_after cursor on the NIP-RS snapshot filter and returns only events it received after that point, with a safety overlap for writes that commit out of order. Every snapshot response carries a cursor, and NIP-11 advertises delta support so clients fall back to complete reads on older relays. Mobile uses a delta only on the sync path, within an hour of its last complete read and only for a cursor from the same relay origin, identity and community. Publish, capacity, absence and own-slot decisions keep using complete snapshots, and a delta never drops peer coordinates. Signed-off-by: Tom Brow <tomb@block.xyz>
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Codex Review Summary: ✅ CompletedThis 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. |
A delta selected and budgeted only the rows received after its cursor, so on an account over the event, stored-byte or encoded-byte budget a small delta succeeded where a full read is refused with 413. The client then treated its state as loaded, accepted Mark Unread, and the full read before publishing rejected the journaled mark. A delta now runs the full snapshot read unchanged (selection, budgets, encoded cap, signature and scope checks) and only then drops the rows received at or before its cursor, so it fails exactly when a full read would. Comparing the cursor in Rust also removes the timestamp cast that turned an out-of-range cursor into a 503. NIP-RS now says when a delta counts as a new snapshot (reconnect catch-up and override gating) and what still needs a complete one. Signed-off-by: Tom Brow <tomb@block.xyz>
During a rolling deploy or rollback, discovery can reach a relay that offers deltas while the query reaches one that predates them, which refuses the cursor with 400. Every retry kept the cursor and failed the same way. A 400 to a delta request now retries once, in the same call, as a newly signed full read. Signed-off-by: Tom Brow <tomb@block.xyz>
Only complete reads refreshed the follow capacity basis, so after a delta resume it went stale both ways: a peer filling the last room left Follow accepting a choice that could never publish, and a peer freeing room left it refusing a choice that fit. The refused tap returns before publication, so no later full read rescued it. Each delta's events now replace or add their coordinates in the basis, so it can only overcount a coordinate deleted since the complete read. Before refusing a follow on a basis that includes a delta, Follow reads the complete snapshot once and checks again. Signed-off-by: Tom Brow <tomb@block.xyz>
When complete reads failed but deltas succeeded (a link too slow for the whole snapshot), each successful delta reset the backoff that belonged to the failing complete read and scheduled another publish, whose complete read failed again. Ten minutes gave about 60 failed complete reads and a sync notice that flickered each time. A failed complete read now drops the delta cursor, so the retry reads the complete snapshot too and the backoff grows as before. Signed-off-by: Tom Brow <tomb@block.xyz>
A 429 on a snapshot read started the rate-limit gate, but no snapshot request waited on it, so a backoff retry or resume inside the pause spent quota and drew another 429. Wait on the gate before the discovery GET and the POST /query, recheck the session context after the wait, and build and sign the NIP-98 request only after it. Signed-off-by: Tom Brow <tomb@block.xyz>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a7ddc3f5d
ℹ️ 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".
A live-ready delta that finished during a refused follow's complete read outranked it, so the capacity basis stayed stale and the retry refused again. The refresh now joins the sync loop as a complete read and rechecks only once a complete basis is installed. A newer tap on the same thread during the refresh keeps its choice. Every failed read now drops the cursor, since the transport can read in full on its own (no delta offered, or the 400 fallback). Signed-off-by: Tom Brow <tomb@block.xyz>
The delta filter truncated received_at to milliseconds, so a row received within the cursor's millisecond but after it was dropped. Signed-off-by: Tom Brow <tomb@block.xyz>
Refused follow taps waiting on a capacity refresh now share the complete read already in flight instead of queueing another. A tap superseded by a newer one on the same thread finishes as a success without writing. The snapshot transport reports when it sends a complete query, so a failed read drops the cursor whenever a complete read was sent, and a failed delta keeps it. Signed-off-by: Tom Brow <tomb@block.xyz>
Signed-off-by: Tom Brow <tomb@block.xyz>
Signed-off-by: Tom Brow <tomb@block.xyz>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Every time the mobile app resumes or reconnects, it downloads the account's whole read-state snapshot: one encrypted kind 30078 event per installation that ever synced. On an account with about 30 installations that is around 1.2 MB per resume, and the client downloads, verifies and merges every event before unread counts settle. Usually only one or two of those events changed.
This PR lets a client ask the relay for only what changed:
received_aftercursor. With it, the relay returns only own-author kind 30078 events it received after that point (delta: true, no completeness claim). Every response, full or delta, carries a newcursor. The cursor is based on the relay's receive time minus a 5-minute overlap, so a device's skewed clock can't hide an event, and a write that commits late is still returned as long as its receive time is newer than the cursor. NIP-11 advertisesdelta: 1, and NIP-RS documents it.Regressions
received_afterand don't advertisedelta, so mobile keeps doing full reads against them.follow:falsethat mutes a thread), but no shipped client deletes thread-follow coordinates, so this only matters for hand-edited state.Validation
Snapshot response size from a local relay built from this branch, for an account with 33 slots of about 36 KB each (random content, so it compresses like real encrypted blobs):
A delta taken within 5 minutes of the previous read also re-sends the slots written in that window (the overlap).
buzz-dbPostgres test for delta reads against a real database, including a write received within the cursor's millisecond.