Repository navigation
feat(relay): read NIP-CW windows oldest first - #9632
Closed
LordMelkor wants to merge 1 commit into
Closed
LordMelkor wants to merge 1 commit into
LordMelkor wants to merge 1 commit into
Conversation
Add `direction: "newer"` to both NIP-CW window modes. A newer window pages from the oldest row in `created_at ASC, id DESC` order, continued by `after`/`after_id`; the other direction's cursor fields are rejected. - Thread mode scans idx_thread_metadata_window backward (no migration), binds the direction and cursor into the tw:1 hash, and accepts `root_aux: false` to leave the root's aux out of the closure. Default requests keep their exact binding. - Channel mode walks the monthly partitions forward two months at a time (`oldest_for`, `Forward::advance`), mirroring the recent-first split, and stops at the first window that fills the page. The head page starts at the month the channel was created, less the write path's created_at tolerance (`channel_floor`), so it never plans the older partitions. Newer 39006 bounds carry a `newer:` d-tag prefix and a `direction` field; older bounds are byte-identical. - Newer pages route to the writer: no cursor bounds the rows they read. - NIP-11 advertises `buzz-window-newer`; NIP-CW and the bridge channel window doc describe both directions. Made with human guidance from the maintainer driving this work. Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Krish Ray <kray@block.xyz>
LordMelkor
marked this pull request as ready for review
November 18, 2026 05:49
LordMelkor
had a problem deploying
to
codex-review
November 18, 2026 05:49 — with
GitHub Actions
Failure
LordMelkor
had a problem deploying
to
codex-review
November 18, 2026 06:10 — with
GitHub Actions
Failure
LordMelkor
temporarily deployed
to
codex-review
November 18, 2026 06:18 — with
GitHub Actions
Inactive
Contributor
Author
|
🤖 Replaced by #9641: the same commit, on a branch in this repo instead of a fork. |
This branch was previously deployed
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
NIP-CW windows can now be read oldest first. Both window modes accept
direction: "newer". A newer page starts at the oldest row and is continued byafter/after_idfrom the previous page's cursor. Thread windows also acceptroot_aux: false, which leaves the root's reactions and edits out of the closure for a reader that already shows the root.The relay advertises this as
buzz-window-newerin NIP-11. Clients that don't ask for it see no change: default requests keep their exact binding, and older 39006 bounds are byte-identical.This is the relay half of block/buzz-app#3660. That PR lets a plugin sort, filter and page a thread's or channel's rows. Reading oldest first lets an "Oldest" view paint its first window after one page. Without it, it has to read the whole conversation newest first. The app works without this relay change, but its scans are slower.
What changed
idx_thread_metadata_windowbackward, so it needs no migration. It binds the direction and cursor into thetw:1hash and rejects the other direction's cursor fields.created_attolerance (channel_floor), so it never plans older partitions.newer:d-tag prefix and adirectionfield.RoutePredicate::Bounded): to a replica only withinreplica_read_max_age, otherwise to the writer. An older continuation page can use a replica because its cursor puts an upper bound on the rows it reads, and the replica fence can cover that bound. A newer page reads up to the present, so no fence covers it.buzz-window-newer, and NIP-CW and the bridge channel window doc describe both directions.Known limits
created_atbefore the channel's creation month (less the write tolerance) is not found by a newer channel read. Examples are rows from restores or raw SQL. The write path rejects such rows, so this needs data that bypassed it.replica_read_max_age, every newer page goes to the writer, not only the first page. The app's reference plugin keeps this bounded at the client: it reads at background priority, and after a reconnect it reads again only while its window is visible, after a random wait of up to 10 s.Related issue
None found.
Testing
All runs were on a separate Linux machine at 605ba9884 (tree identical to this PR's head 73d76b3; only the commit message trailers changed), on main c01d329:
cargo fmt --check, andcargo clippy -p buzz-core -p buzz-db -p buzz-relay --all-targets -D warnings: clean.cargo nextest(buzz-core, buzz-db, buzz-relay): 2,379 passed.scripts/postgres-test-run.sh, same crates): 1,559 passed.just test-unitpasses for the changed crates, but three unrelated crates (buzz-voice, buzz-acp, buzz-agent) could not build there because thesherpa-onnx-sysbuild script failed to download its library; desktop Tauri clippy and tests could not build without glib/GTK on that machine. No desktop, agent or voice code uses the changedbuzz-corethread-window API (git grep).direction: "newer") and newest first. Oldest paged forward to the last reply and to the last message, past the app's 2,400-row channel window, and every window matched a database oracle. All 33 checks passed.Made with human guidance from the maintainer driving this work.
🤖 Generated with Claude Code