~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

pds-server: a space's listRecords cursor is a record's URI, as the reference's is

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:pds-server/space-record-cursor

knotless reads a private repository's refs with a space listRecords page started below a key it chooses, a cursor it builds as a record URI, as the reference's cursors are. Monolith answered {collection}/{rkey} cursors and read a URI as a byte position below every key, so knotless saw no refs and every push to a private repository on Monolith failed. Now Monolith's cursor is the reference's: the last record's URI, taken as a position whether or not the record exists.

Claude Opus 5.5 · high

What changes

Spec. spec/SPACES-REPO.md, "Each read": a full listRecords page answers the URI of its last record, {space}/{repo}/{collection}/{rkey}, as getRecord answers it; a cursor of that form, of the space and repo asked, is a position whether or not such a record is or was there, so {space}/{repo}/{collection}/{prefix}.~ starts below every key beginning {prefix}.. "Cursors": a listRecords cursor is no longer the server's to choose, since clients build them; one with a / that is not a record URI of the space and repo asked is 400 InvalidCursor. listRepoOps and listSpaces cursors are as they were.

Harness. harness/spaces/repo.mjs, listRecords: each cursor answered must be the URI of the page's last record; and one more read, on both sides, from a cursor built for a key (a written record's path with ~ after it, which need not exist), against the records the harness wrote below it. The reference passes both, which confirms its cursors are the last record's URI and that it takes a built one as a position.

Server. crates/pds-server/src/space_repo.rs, list_records: the cursor answered is {space}/{repo}/{path}; one taken must start with {space}/{repo}/ of the request, and the rest is the position. Its unit tests use URI cursors, and assert a bare path and another repo's URI are InvalidCursor.

A .changeset (patch): clients see the cursor's form change.

Why

The owner's account moved to Monolith; knotless's spaces-alpha cutover builds cursors as the reference has them (crates/knotless/src/remote.rs, Remote::cursor, keys::scan_cursor), so knotless repo refs and git push on private repositories saw an empty repository and tried to create refs that exist (RecordAlreadyExists). Taking the reference's cursor form is the change that lets every alpha client page Monolith as it pages the reference; knotless building its own would leave the next client hitting the same.

How it was checked

  • node spaces/compare.mjs --seed 1 against the pinned reference: passes with the fix.
  • The bug planted: the server's space_repo.rs as on main, the same run fails at "listRecords from a built cursor" (seed 1: com.atproto.space.listRecords differs).
  • cargo test -p pds-server --lib space_repo: 14 pass.
  • just quick: run before queueing; the gates are the gates workflow's.

Shortcomings

Cursors of the old form that a client holds mid-listing across the deploy are refused InvalidCursor; it starts the listing again.

Approved

The pull makes a space's listRecords answer the last record's URI as its cursor. It also takes a URI of the same space and repo as a position, whether or not the record exists.

  • Server: I read list_records in full. The prefix strip, the / check and the upper-bound logic are correct. A cursor below the collection's lower bound gives an empty page, which is right.
  • Spec: the change is in spec/SPACES-REPO.md, in both "Each read" and "Cursors".
  • Harness: the new checks are stricter. The built-cursor read compares both sides against what the harness wrote.
  • Changeset: it is present and written for clients.

One nit: the doc comment on list_records still says the cursor is "the last path of the page before". It should say the last record's URI.

All checks have passed

4 passed, 1 skipped

Merged as f722cb1