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

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

web: Groups, pools and private galleries call grain-serve's methods

Merged
Merged chadtmiller.com asked to merge into feature/rust from grain.social/grain:web/space-method-names

What changes

The web's groups, pools and private galleries reach grain-serve. Every call the web made by a social.grain.unspecced.* name is now the name grain-serve serves, through $lib/xrpc's query and call, typed by the lexicons npm run lex generates, as the rest of the web's calls already are. Nothing in web/src imports $hatk/client any more.

Was (social.grain.unspecced.*)Is
getSpaceSupportsocial.grain.server.getSpaceSupport
listPrivateGalleriessocial.grain.privateGallery.listPrivateGalleries
getSpaceMemberssocial.grain.privateGallery.listMembers
listSharedGalleriessocial.grain.privateGallery.listSharedPrivateGalleries
getPrivateGallerysocial.grain.privateGallery.getPrivateGallery
createPrivateGallerysocial.grain.privateGallery.createPrivateGallery
addSpaceMembersocial.grain.privateGallery.addMember
getGroupsocial.grain.group.getGroup
getGroupHostsocial.grain.group.getGroupHost
listGroupssocial.grain.group.listGroups
getGroupSubmissionssocial.grain.group.getSubmissions
createGroupsocial.grain.group.createGroup
joinGroupsocial.grain.group.joinGroup
leaveGroupsocial.grain.group.leaveGroup
listPoolGalleriessocial.grain.group.listGalleries
listPoolFeedsocial.grain.group.listFeed
getPoolGallerysocial.grain.group.getGallery
createPoolGallerysocial.grain.group.createGallery
deletePoolGallerysocial.grain.group.deleteGallery
createPoolCommentsocial.grain.group.createComment
deletePoolCommentsocial.grain.group.deleteComment
putPoolFavoritesocial.grain.group.putFavorite

The shapes are the same. Each old and new lexicon was compared, less descriptions: the parameters, input and output agree, the defs the old ones held for themselves (photoInput, privateGallery, privateItem, memberView, privateGalleryRef, sharedGalleryRef, poolGallery, poolFeedItem, poolComment, poolAuthor) moved unchanged to social.grain.privateGallery.defs and social.grain.group.defs, and createGroup gained its errors. The handlers' parameters (space, group, did, rkey, actor, gallery) and verbs are those the web already used. What the web adapts is only the types: DIDs and AT URIs it holds as strings are cast to DidString and AtUriString where the generated input wants them, uploaded blobs to BlobRef and a comment's facets to the input's facet type, listGroups with no gallery asks with {}, and a pool's comments are cast to the CommentView the sheet renders, as before.

getSpaceSupport moves to social.grain.server. Whether the caller's PDS serves spaces is a question about the server, which groups ask as private galleries do, the Groups tab first; it sits beside deleteAccount and getSitemap, as com.atproto.server.describeServer says what a server supports. The lexicon moves from privateGallery/ to server/, with grain-serve's route, its tests, the harness's pending list, the README's table, hatk.generated.ts (regenerated) and the web's query. No app calls it, so nothing released has the old name.

The pool's methods sit one level under social.grain.group. social.grain.group.pool.listGalleries is social.grain.group.listGalleries, and so on for all eight, so no grain lexicon nests deeper than social.grain.<name>.<method>. The pool's defs (poolFeedItem, poolGallery, poolComment, poolAuthor) join social.grain.group.defs; no name clashes. No app calls them.

A test that the web calls only what grain-serve serves. every_method_the_web_calls_is_served, in crates/grain-serve/tests/health.rs, reads web/src (less its generated lexicons) for each NSID passed as the first argument of query, call or upload (or a name one is imported as, such as xrpcQuery), and asks grain-serve for each, served with an in-memory index and a DID as the web's is (a bare server answers 501 for whatever needs either), a query by GET and a procedure by POST, through common::Served so the answers check sees the answers. It fails on 501 (not served) or 405 (served as the other kind), naming the file. It finds 61 methods today, and fails if it finds fewer than 41, so a scan that stops finding calls does not pass.

Why

On next.grain.social the Groups tab never showed: Sidebar.svelte shows it when spaceSupportQuery() says supported, and that asked social.grain.unspecced.getSpaceSupport, which grain-serve answers 501. Every call in this table failed the same way. A test against the router, rather than a grep of its route table, holds however a route is written (a const in spaces/, a literal in lib.rs).

How it was checked

  • Each new name against next.grain.social, unauthenticated GETs only: the queries answer 400, 401 or 200, the procedures 405 (routed, as POST), and social.grain.unspecced.getSpaceSupport 501.
  • The scan, run by hand over web/src in a Python copy of it: the 61 methods it finds are every one grep finds called, and no other method in web/src is unrouted beyond these 22.
  • npm run check here, once: no errors, all files formatted.
  • The rest is CI's: check for types and format, harness for the new test and the answers it records.

Shortcomings

  • createGroup's handler reads an optional description, and the web sends one, but social.grain.group.createGroup does not declare it. Left alone here, as the server's shape is the lexicon's to say; it wants an optional description added to that lexicon.
  • lexicons/social/grain/unspecced/* for these 22 are no longer used by the web, or by grain-serve, or by grain-ios as far as its local checkout shows. They are still served by the hatk server in server/xrpc/ (and test/groups.test.ts asks getGroup and listGroups), which production runs until cutover, so they stay until then, with the rest of unspecced/.
  • The private gallery page still names all three reasons a gallery would not open, where the XrpcError it now gets carries which; its comment says so.
  • Not tried logged in: writes on next reach production.

🤖 Generated with Claude Code

chadtmiller.com added 1 commit
Approved

This moves the web's 22 social.grain.unspecced.* calls to the NSIDs grain-serve serves, through $lib/xrpc's query and call. It also adds every_method_the_web_calls_is_served, which scans web/src for the NSIDs passed to query, call and upload and fails on a 501 or 405 from the router.

I found nothing that must change. The renames match the table in the description. The casts are narrow. The scan skips calls whose first argument isn't a string, such as spaceSupportQuery(). Its floor of 41 guards against a scan that stops matching.

Two things to know:

  • When I read it, the check, harness, rust and test workflows were still queued or running, so I haven't seen the types or the new test pass. Don't merge until they do.
  • A few calls still use as never (createGallery, createPrivateGallery, createComment). That hides any drift from the generated input types. The description gap on createGroup is already listed under shortcomings, so I won't ask for it again.
Approved

The new commit cafedc5 does what I noted last round. The pool and private gallery writes now cast only the blobs, the DID and the facets to the generated input types, where the whole input used to be cast to never. I found nothing else that must change.

The check, harness, rust and test workflows were all still queued when I read this. I haven't seen the types or every_method_the_web_calls_is_served pass, so don't merge until they do.

chadtmiller.com added 1 commit
Approved

The new commit 03a7f0e changes only the test. It now serves grain-serve with an in-memory index and a DID, as the web's server has. A bare server answered 501 for methods that need either, and that would have failed the test for routes that are served. I checked that App::bare, the App.index and App.did fields, Index::memory and common::served_app all exist on this branch. I found nothing that must change.

The check, harness, rust and test workflows were still queued when I read this, so I haven't seen the types or every_method_the_web_calls_is_served pass. Don't merge until they do.

Approved

The new commit 427fee0 moves getSpaceSupport to social.grain.server.getSpaceSupport. That is the name grain-serve serves in spaces/support.rs, and its lexicon is lexicons/social/grain/server/getSpaceSupport.json. The web's queries.ts now calls that name, and no call to the old privateGallery.getSpaceSupport name is left. I found nothing that must change.

  • Stale description: the first row of the table still says social.grain.privateGallery.getSpaceSupport. Update it so it matches the code.
  • Checks: the check, harness, rust, test and lexicons workflows were all still queued when I read this. I haven't seen the types or every_method_the_web_calls_is_served pass, so don't merge until they do.
chadtmiller.com added 1 commit
Approved

The new commit 97abdb8 moves the eight pool methods from social.grain.group.pool.* to social.grain.group.*. I found nothing that must change.

  • Renames: social.grain.group.pool no longer appears anywhere in the repo. social.grain.group.listFeed is now the same name in spaces/pool.rs, tests/spaces.rs, the lexicon, hatk.generated.ts, the lexicons README and the web's queries.ts. I only spot-checked listFeed, not the other seven.
  • Description: the first row of the table now matches the code, and the description covers the pool move.
  • Checks: the check, harness, rust, test and lexicons workflows were all still queued when I read this. I haven't seen the types or every_method_the_web_calls_is_served pass, so don't merge until they do.
chadtmiller.com added 2 commits
Merged as 62906a1
Part of a stack of 2
  1. web: Groups, pools and private galleries call grain-serve's methods Landed as 62906a1
  2. main