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

A space's access record grants each role scopes there

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:proposal/access

What changes

The access record grants scopes. fyi.opensocial.access takes the opensocial proposal's shape: grants, one fyi.opensocial.defs#spaceGrant a role (its id and the OAuth scopes it holds in this space and no other), and public, in place of readableBy, writableBy's default, credentialScopes and createdAt. The host reads each grant's scopes as it reads a token's, against the space the record is in:

  • a role granted read there (space:<type>?action=read, or a scope naming no action) reads the space;
  • a member whose roles grant read writes there in their own name, where before any member could;
  • a role granted a space scope naming collections writes those as the group there, as credentialScopes said, and may publish them in the public repo as before;
  • public is anyone signed in, never anyone at all: a credential still takes a signed-in user.

A scope naming another type, key or authority grants nothing in the space.

What the proposal's shape cannot say is kept beside it. writableBy stays, optional, for a space where fewer write in their own name than read it (an announcements channel). people, a space for chosen people by DID, stays and is now in the lexicon. Its reviewers are the roles granted read.

createSpace takes and answers the proposal's shape. It takes type (was spaceType), skey, access (fyi.opensocial.defs#accessConfig: grants, public, and this host's writableBy) and index (default true; false leaves the space out of the index). It answers space and strong references to the access record and, when indexed, the index entry. It refuses the meta and members types (ReservedSpace), a role the group has not (UnknownRole), a scope that is no space scope (InvalidScope), two grants of one role, and an access record no one but the group would read. group and name stay, as every method here names its group and the index entry keeps its name.

updateSpace and deleteSpace follow. updateSpace takes access, replacing the record whole, in place of the three lists, with the same checks; the members space must still grant member read, and its writableBy stays unset. Meta's declaration follows public. deleteSpace deletes a space left out of the index too, and refuses meta and members with ReservedSpace (was WellKnownSpace).

Everything that reads access follows. A new group's meta is public (or grants each named role read) and grants admin space:fyi.opensocial.meta?collection=fyi.opensocial.profile&collection=fyi.opensocial.rule; its members space grants member space:fyi.opensocial.members?action=read, as the proposal's example has it. getGroup shows a space's public, grants, people and writableBy to whoever reads it; listGroups lists a group whose meta is public. The authority, the index, tokens, getGroupAuth and the console's visibility setting read the grants. Moving a group needed nothing: it carries access records as records.

docs/design/spaces.md and groups.md say what the access record is now.

Why

The host follows the proposal's records and methods, so that apps written to it work here, in its own fyi.opensocial.* namespace. The lexicon check lets the proposal's bare-string scopes, its type field name and its required fields through, each by its exact finding, and lists the removed fields whose names the code still quotes elsewhere.

How it was checked

The rbac, group spaces, groups, tokens, group tokens, OAuth scope, index, moderation, group config, migration and interop tests pass with the new shape, with new cases for grants in another space, collections written by grant, a space left out of the index, the strong references createSpace answers, and each refusal. The opensocial command's tests, clippy, node harness/lexicons.mjs, node harness/docs.mjs and the console's npm run check pass. Coverage and e2e are left to CI.

Shortcomings

  • Access records still change only through updateSpace, not through com.atproto.space.* writes as the proposal has it, and neither checks that the writer grants only scopes and roles they hold (assignable): that belongs with permission sets and assignable roles.
  • A grant naming a permission set (include:…) is refused as InvalidScope: the host expands no permission set in an access record yet.
  • createSpace is still asked as the member, with space.create, not with a group-DID session holding manage=create.

🤖 Generated with Claude Code

Approved

This moves the space access record to the proposal's shape: grants per role, public, and an optional writableBy. createSpace, updateSpace and deleteSpace follow, as does everything that reads access.

I read the core logic and found nothing wrong. That covers rbac.rs (Access::of, reads, writes, can_read, can_write_own), oauth_scope.rs, group_spaces.rs and group.rs. Grants count only in the space their record is in, and public stays "signed in". The create path ends the space again if its access record fails to write. updateSpace still guards the members space (member must keep read, no writableBy), and deleteSpace now handles a space that isn't in the index.

I did not read the following files in this review:

  • the other src files: actors.rs, authority.rs, authorization.rs, group_api.rs, group_tokens.rs, index_api.rs, token_writes.rs;
  • the tests;
  • the lexicons and harness/lexicons.mjs;
  • the docs;
  • the console route.

On checks, check, lexicons, docs and e2e passed. test was still running and web still queued when I looked, so the 100% coverage gate and the Rust tests are unconfirmed. Make sure test passes before merging.

One thing to be aware of: access records already stored with readableBy or credentialScopes read as having no grants once this lands, so they would be unreadable by anyone but a public-less group. This is fine if no host holds such data yet, as the pull's framing implies.

Merged as 4b634eb