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

Groups are started, read and listed

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

What changes

Groups are started, read and listed.

  • fyi.opensocial.createGroup: the caller, signed in with service auth from their own PDS for this host's SERVICE_DID, starts a group as founder. It gets:
    • its account;
    • its meta space: profile, labeler, and an access record;
    • its members space: an access record, the admin and member roles, the permissions record, an index entry for each space, and the founder's and stewards' memberships as admins;
    • a declaration in its public repo if anyone may read meta.
    • GROUP_FOUNDERS (new) limits who may start groups.
  • fyi.opensocial.getGroup: the group as its caller may see it:
    • profile and rules, to whoever may read meta;
    • the caller's standing: member, roles, actions, and whether they've accepted;
    • for a member: its members, roles, what each role may do, and its spaces with their access records, shown to whoever may read each.
  • fyi.opensocial.listGroups: every group, unauthenticated. Each is listed by handle, plus profile and rules where meta is public.

Access records decide. rbac.rs holds the rules over a group's records, ported from the prototype's access.ts and roles.ts:

  • who reads a space, who writes in it in their own name, and spaces for chosen people;
  • each action answered by one scope, with roles composing by union.

Host::may now asks a group space's access record, against the user's roles from their membership. So credentials and admitted writes follow the group's own records, alongside the grants from the last pull.

A delegation token is spent once it buys a credential, not before the read check, as the last pull's review suggested. A refused token is no longer used up.

docs/design/groups.md is new. The plan marks this part of step 4 done, and docs/reference/config.md lists GROUP_FOUNDERS.

Why

This is step 4d's first part: groups themselves, on the authority from 4c. It follows the prototype's bootstrap.ts and methods/groups.ts. It changes these:

  • The spaces are decided by their access records directly. The prototype gave each a managedspace policy naming the host, then asked itself.
  • Lists in records are of objects ([{role}], [{scope}]), as this host's lexicons were reshaped to.
  • joinPolicy takes either the profile's words or createGroup's known values (fyi.opensocial.profile#request), which the prototype's lexicons didn't agree on.
  • A group's address is its handle.

How it was checked

  • tests/groups.rs:
    • Starting a group: every record, the memberships of founder and stewards, the declaration, and both spaces under the group's authority.
    • getGroup for each viewer:
      • the founder sees everything, including rules in order, avatar and topics, viewer state, members, roles, bindings and spaces;
      • a plain member sees an admin-only space by name, without who reads it;
      • a member who has written into the members space has accepted;
      • a stranger and an anonymous caller see only the public face.
    • A members-only group shows strangers nothing and has no declaration.
    • Access records decide may, credentials, and refusals. A refused token isn't spent.
    • listGroups with public and closed groups, a non-group account, and more than a page of accounts.
    • Every refusal of createGroup:
      • no auth, another audience, another method;
      • missing or bad fields;
      • a taken handle (HandleTaken) and one outside the domain;
      • GROUP_FOUNDERS.
    • A token for <SERVICE_DID>#fragment is accepted.
  • tests/rbac.rs:
    • reads and writes by access record, including chosen people and reviewers;
    • every action by its scope, and scopes that grant nothing;
    • union of roles, and the public-repo collections;
    • join policy words.
  • just cov: 100% of lines and functions. Clippy is clean.

Shortcomings

  • A member is named by DID alone (actorView has no handle or profile yet), and getGroup has no join requests. Both come with membership.
  • Profile, rules, handles, activating, deleting, and spaces made by members are still to come in 4d.
  • Changing an access record doesn't revoke credentials already issued: they last up to an hour.

🤖 Generated with Claude Code

Approved

This adds createGroup, getGroup and listGroups. It adds rbac.rs, so a space's access record decides Host::may. It also moves the delegation-token spend to after the read check. I found nothing that must change.

  • Access check: the record is consulted first, and the old grants and public_read still apply if it denies. Anonymous callers are unchanged. That matches the stated "alongside the grants" design.
  • Token spend: the spend now happens after may and before the credential is signed. A refused token is no longer used up, which answers the last review.
  • getGroup disclosure: members-space data is only returned when the members space's access record lets the caller read it. Each space's access record is only shown to those who can read that space. This looks right.
  • createGroup: it validates stewards, the join policy and GROUP_FOUNDERS before creating the account. If a later space_write fails, the handle stays taken by an account getGroup and listGroups hide, because they require the members space. This is a minor point and could wait for the lifecycle work.

The test and check runs were still queued when I looked, so I can't say they pass. I did not read tests/groups.rs (580 lines). The checks and the 100% coverage gate cover it.

Merged as 6f6b4f7