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

Spaces are kept under policies and changed through atproto's space methods

Merged
Merged chadtmiller.com asked to merge into feature/proposal-nov from chadtmiller.com/group-host:spaces/policy

Each group space is now kept under a fyi.opensocial.policy ({publicRead, unlisted, grants[{role, read, write, scopes}]}) in place of access records, and spaces are made, changed, read and ended only through atproto's com.atproto.space.createSpace/updateSpace/getSpace/deleteSpace, called as the group.

Claude Opus 5.5 · high effort

What changes

Policies. The host keeps each space's policy, publishes it as the group's com.atproto.space.policy/self in the space, and keeps the fyi.opensocial.space index in the members space in step with unlisted; direct writes of either are refused. fyi.opensocial.access, our createSpace/updateSpace/deleteSpace, people, writableBy, the public audience, the index entry's name and metaReadableBy (now metaPublicRead) are gone.

Space methods. atproto's four methods are served for group sessions (OAuth or a getGroupAuth token, which now carries the manage= ops the member may use, and may be asked for a space not yet made). UnsupportedPolicy for any other $type; ScopeMissing without the manage= op; NotAuthorized unless a role grants space.create/space.configure (now space:*?manage=update)/space.delete or the space's own grant manages it. meta and members can't be made or deleted.

Escalation. An update changes only grants of roles in the user's assignable union (rbac::assigns, so * covers every role), adds only scopes they hold, and grants read/write, or turns on publicRead, only where they have it (NotAuthorized).

The members space stays members'. Every member holds member; an update of the members space that takes read or write from member, or turns on publicRead, fails MembersSpaceFixed (in docs/reference/api.md; atproto's updateSpace lexicon is upstream's, unchanged). Other roles may be given write there: only members hold roles.

Read and write. Roles granted read read; publicRead lets anyone read through the space credential path (our own listSpaceRecords/getSpaceBlob still ask for sign-in). Only roles granted write are in the writer set; a policy change or role change prunes those who lose it.

New groups and moving. Meta: members read, admins read and write profile and rules, publicRead unless metaPublicRead: false. Members: members read and write. The admin role holds, besides every action's scope and repo:*, space:*?collection=*: any record as the group in any of its spaces, so founders may give any scope a policy grant may hold. migrateExport's meta part is a space meta archive with the policy; account import maps personalspace/memberspace policies to fyi.opensocial.policy with unlisted, and publishes policies only once the members space exists. getGroup lists spaces in index order again, then unlisted ones the viewer reads.

Console, CLI, MCP, kicker. The console's visibility setting runs updateSpace on meta, keeping the rest of its policy (looked at with just look: listed, set to members only and back, as alice and as bob, desktop light and phone dark). opensocial space create <group> <type> --policy <json> [--skey] / space_create run createSpace with a group token.

Why

Upstream's proposal (Nov 2026) makes the space policy the one place access lives, and atproto's own space methods the way to change it.

How it was checked

Acceptance tests in group_spaces.rs: create/update/delete/get with scope and role checks (including a token whose member has since lost the role), UnsupportedPolicy, the published policy and refused direct writes, unlisted and the index, read vs write and pruning, the escalation refusals (role not assignable, read, write or publicRead not held, scope not held), a founder giving collection, read_self and manage scopes in a calendar's policy where a member without them can't, MembersSpaceFixed, meta/members undeletable. Also oauth_scope.rs (manage scopes), group_tokens.rs, tokens.rs, rbac.rs, groups.rs (the admin role's scopes; an unlisted space shown only to its readers), migration.rs (the meta archive round trip, and a source whose space repo isn't what its commit says), opensocial space create and the space_create tool end to end, and the account import publishing the policy of the space the group governs. All six checks run on the pull.

Shortcomings

  • App-password sessions (atproto transition:generic) never reached spaces before this pull either, so they can't call the space methods; left as is.
  • A policy scope naming another authority (authority=did:…) isn't covered by the admin's space:*?collection=*, which is for the group's own spaces; only someone holding that exact scope may add it.
Asked for changes

This pull moves group spaces from access records to fyi.opensocial.policy and serves atproto's four space methods. I read the core: group_spaces.rs and rbac.rs, plus token_writes.rs for context. I did not read the other ~80 files (docs, lexicons, tests, web, CLI/MCP, import and migration). The diff was too large to read in full, so none of them is covered by this review.

Two gaps in updateSpace come from guards the old code had and the new code dropped:

  1. The members space can be set to any policy. The old update_space kept the members space readable by member and refused changes to who may write in it. That second guard matters because writing there in your own name is joining. The new update_space_as accepts any valid policy for it, because own doesn't exclude reserved types. An admin holding space.configure can therefore lock every member out of the roster, make the roster publicRead, or let non-members write membership records. The docs say members read and write there. Please reject, or force, the members policy so members keep read and write and publicRead stays false. Add a test for it.
  2. publicRead and unlisted are not covered by escalates. escalates stops a user granting read or write they don't have to a role. It doesn't stop them setting publicRead: true. A role that manages a space through its own policy grant or through space.configure, but doesn't read it, can make it public and then read it through the credential path. Require that the user can read the space before they turn publicRead on, and add a test for it.
crates/group-host/src/group_spaces.rsline 274Outdated
if !self.may_manage(group, member, &now, asked)? {
return Err(not_authorized("no role of yours may change this space"));
}
let policy = checked_policy(self, group, &body["policy"])?;
review.knotless.dev

Nothing checks the members space's policy here. The old code kept it readable by member and refused changes to who writes in it. Add that back, or the space can be locked out or opened to public reads or to non-member writes.

crates/group-host/src/group_spaces.rsline 356Outdated
now: &Policy,
next: &Policy,
) -> Result<(), XrpcError> {
let union = assignable(grants, roles, None);
review.knotless.dev

escalates compares only each role's grant. A change that sets publicRead to true, or unlisted, isn't checked against what the user holds, so a manager who can't read the space can make it public and read it.

Asked for changes

Neither of the two findings from my last review is fixed. I checked update_space_as, escalates and checked_policy in crates/group-host/src/group_spaces.rs at 719adba. I did not read the rest of the new diff, which is very large.

  1. Members space policy. update_space_as still accepts any valid policy for the members space. checked_policy only checks the $type, the roles and the scopes, and escalates only compares per-role grants. So an admin with space.configure can still:

    • remove read or write from member, which locks members out of the roster or stops them joining;
    • set publicRead: true on the roster;
    • grant write to a role that isn't member.

    Please reject such updates for the members space, or force its policy so that member keeps read and write and publicRead stays false. Add a test for it.

  2. publicRead and unlisted. escalates still ignores publicRead. A manager who can't read the space, because their role is space.configure or a policy manage grant without read, can set publicRead: true. They can then read the space through the credential path. Please refuse turning publicRead on from off unless now.can_read(roles) holds for the user. Add a test for it.

Both fixes are small and sit in update_space_as and escalates.

Asked for changes

Neither finding from my last two reviews is fixed. The only change since 719adba is in tests: group_spaces.rs, group_tokens.rs and migration.rs. I read escalates at the head and it is unchanged. It still has no check on publicRead.

  1. Members space policy. update_space_as still accepts any valid policy for the members space. An admin with space.configure can remove read or write from member, set publicRead: true on the roster, or give write to a role that isn't member. Please reject such updates for the members space, or force its policy so that member keeps read and write and publicRead stays false. Add a test for it.

  2. publicRead escalation. A manager who can't read the space can set publicRead: true and then read it through the credential path. Please refuse turning publicRead on from off unless now.can_read(roles) holds for the user. Add a test for it.

Both fixes are small and sit in update_space_as and escalates.

Asked for changes

The only change since 624aba0 is two test lines in group_spaces.rs, which now use std::slice::from_ref. Neither earlier finding is fixed. I checked escalates in crates/group-host/src/group_spaces.rs at the head, and it still checks nothing on publicRead.

  1. Members space policy. update_space_as still accepts any valid policy for the members space. An admin with space.configure can remove read or write from member, set publicRead: true on the roster, or give write to a role that isn't member. Please reject such updates for the members space, or force its policy so that member keeps read and write and publicRead stays false. Add a test for it.

  2. publicRead escalation. A manager who can't read the space can set publicRead: true and then read it through the credential path. Please refuse turning publicRead on from off unless now.can_read(roles) holds for the user. Add a test for it.

Both fixes are small and sit in update_space_as and escalates.

Approved

Both findings from my earlier reviews are fixed in the changes since 87029a1. I read only that diff, not the whole pull.

  1. Members space policy. update_space_as now returns MembersSpaceFixed unless member keeps read and write and publicRead is off. The new test covers dropping read, dropping write, moving the grant to another role, and publicRead. It also checks that a valid policy is accepted.
  2. publicRead escalation. escalates now refuses turning publicRead on from off unless the user can read the space, and a test covers it.

One more change: new groups' admin role now holds space:*?collection=*, so admins can add collection scopes to a policy. The docs and the getGroup test were updated to match.

Nothing else I found needs to change.

Approved

The only change since my approval at 3ed4ce6 is in crates/opensocial/tests/commands.rs. The account-move test now expects the published com.atproto.space.policy/self record in each moved space's paths. That matches the pull's described behaviour, and it changes no production code. My earlier approval stands.

Approved

The only change since my approval at 7c3441c is a test edit in crates/opensocial/tests/commands.rs. The account-move test now expects no published policy record in the calendar's paths, and the comment notes that only the forum, now a group's, has one. No production code changed, so my earlier approval stands. I didn't check this expectation against the import code. It's a test-only change, and the test run would show a mismatch.

Approved

The only changes since my approval at 7671149 are tests: an MCP planning test for space_create, a check in group_spaces.rs that a token whose roles are gone can't updateSpace, an unlisted-space visibility check in groups.rs, an MCP space_create run in mcp.rs, and a CLI space create run in commands.rs. No production code changed, and the tests cover behaviour the pull describes. My earlier approval stands.

Approved

The only changes since my approval at 022e2a8 are tests. group_spaces.rs now checks that getSpace on a space that doesn't exist returns InvalidRequest. migration.rs now checks that an import whose policy doesn't match the lexicon (grants is a string) fails with InvalidArchive. No production code changed, and my earlier approval stands.

Merged as 6f2e276