Skip to content

feat(authz): governed groups bridge + grant ceilings (#797 P2) - #85

Merged
PMQ9 merged 8 commits into
wiki-v2from
feat/797-p2-fork
Nov 10, 2026
Merged

PMQ9 merged 8 commits into
wiki-v2from
feat/797-p2-fork

Conversation

@PMQ9

@PMQ9 PMQ9 commented Nov 10, 2026 •

Copy link
Copy Markdown

Fork half of cccvu/wiki-v2#797 P2. It merges two branches built on 74b47d40, the tip of wiki-v2: feat/797-groups-bridge (F1, b128cd03) and feat/797-page-grant-ceilings (F2, 616234ff). The server changes are all under authz/, service-bridge/ or docs/integrations/. Review rounds added small client changes in upstream-owned files, each documented in the super repo's UPSTREAM_MODIFICATIONS.md (seams 9, 38, 140, 144 and 214–218).

What it adds

Groups bridge (/api/service/groups, scopes groups:read / groups:write). These routes hold data only; the platform authorizes first.

  • Reads: list groups (q, limit), get a group, page through its members (keyset, with externalId), look up the groups one identity is in (never provisions it), and usage (what a group grants).
  • Writes: create, rename, delete, add members and remove a member.
    • Add takes 1..200 user externalIds. A group is never a member of a group.
    • Delete is refused with 409 group_in_use { spaceCount, pageCount } while the group still grants anything.
    • Remove-member is a narrowing route (Authz-Propagation).
  • Default group:
    • POST default/ensure is the only route that changes it. It is refused with 409 basic_group_has_grants while any live space membership or page grant names it.
    • Every other write to it answers 409 default_group_immutable.

Space members. addSpaceMember / previewSpaceMember take externalId XOR groupId, plus an optional mode of set (the default) or atLeast. They now answer groupId and applied, and userId is null for a group.

INV-2: space grant ceiling (SpaceGrantCeiling). A write that raises a membership must be covered by what the acting human holds on the space:

Role granted Acting human needs
reader space#view
writer space#edit and space#share
admin a live direct admin row (own or through a group), or workspace#admin_cascade
  • The actor's own rows decide first, under the space lock. The PDP is asked only after a settle fence.
  • Refusal is 403 grant_exceeds_actor. An unconfirmed fence is 503 grant_unconfirmed, and a PDP that cannot answer is a retryable 503.

INV-4 / INV-6: page grant ceilings (authz/page-restriction). These apply to the relayed page-ACL routes.

  • INV-4: add-permission, and an update-permission that raises a role, need the actor's own page#view (reader) or page#edit (writer), or workspace#admin_cascade.
    • The check runs under the page ACL lock. The PDP answer is read after a settle fence, while the transaction holds no xid.
    • Refusal is 403 grant_exceeds_actor, audited page.acl_write_refused. An unconfirmed fence is 503 grant_ceiling_unconfirmed.
    • A grant that passes only through the admin disjunct is audited page.acl_admin_override_grant (log token PAGE_ACL_ADMIN_OVERRIDE).
    • Lowering and removing a grant are unchanged.
  • INV-6: a group grantee on an add or a raise is 400 group_grant_not_allowed_on_restricted_page. Existing group grants are kept and reported by a read-only keyset listing.

INV-5: the default group is never granted. It is refused at every space sink (400 basic_group_not_grantable, re-role included; removal is still allowed) and at the page sink through INV-6.

directoryRead remote-refusal family. In remote mode the native workspace members, invitations, group list / info / members and space members reads answer 404 and are audited as directory.native_read_refused. The public invites/info stays reachable. PdpSearchService returns group suggestions only to a caller who administers the workspace or a space. ServiceGroupController.removeMember joins NARROWING_ROUTES.

Bridge contract (service-bridge.openapi.json)

  • info.version goes from 1.15.0 to 1.16.0. F1 left the bump to the integrator.
  • The 11 group operations each declare RatePrincipal.
  • The description now names the space-member directory read and documents the relayed page-ACL ceilings (INV-4 / INV-6).
  • docs/integrations/authorization/README.md gains the groups family, a 1.16.0 section and the directory-read refusals. It also replaces the stale "reads stay reachable" line.

Integration notes

  • Both merges were clean: F1 and F2 touch disjoint files.
  • One flaky spec in F1 was fixed (service-group.pg.spec.ts, keyset paging). Paged member order is (created_at to the millisecond, id::text) and unpaged order is (created_at, id), the same split as listSpaceMembers. Two members added within one millisecond could therefore sort differently. The spec now compares the keyset pages against one paged listing. It passed 4 times in a row after the change.

Test results (local, Node 26)

  • scripts/check-upstream-boundary.sh: boundary intact, and the brand guard passes.
  • scripts/ci/docmost-server-typecheck.mjs: forward and reversed passes clean (865 roots).
  • Jest over src/authz src/service-bridge src/editor-compat src/common/helpers/prosemirror src/integrations/import (--maxWorkers=2 --workerIdleMemoryLimit=1G): 240 of 241 suites, 4030 passed, 3 failed.
    • The 3 failures are the known deep-value stack tests in authz/collab-ingress/update-guard.spec.ts. The same 3 fail on the base 74b47d40 locally, so they come from Node 26; CI runs Node 22.
  • Real-Postgres lane (postgres:18, AUTHZ_REQUIRE_PG=1, in band; 25 authz / 19 service-bridge / 2 editor-compat specs): 44 of 46 suites passed on the first run.
    • service-group.pg.spec.ts: the flaky spec fixed above.
    • idempotent-page-create.pg.spec.ts: a 5 s conversion timeout under machine load. It passes when rerun alone, and the merge does not touch it.

Follow-up

The super-repo re-pin PR follows on cccvu/wiki-v2#797. It carries the platform half and the new log tokens (PAGE_ACL_ADMIN_OVERRIDE, PAGE_ACL_CEILING_UNCONFIRMED, SPACE_GRANT_UNCONFIRMED, GROUP_WRITE_BUSY, BASIC_GROUP_HAS_GRANTS) in check-infra-config LOG_TOKENS.

Do not merge before the super-repo PR is reviewed.

🤖 Generated with Claude Code

Review rounds (on cccvu/wiki-v2 PR 804)

  • Round 1 (9fa24412): in remote mode the settings sidebar hides Members and Groups, and the space Members tab shows only the Admin Console note. The restricted-page picker offers people only (MultiMemberSelect includeGroups), and a group grant row is never offered a raise. grant-ceiling-parity.spec.ts pins the ceilings' local-allow facts.
  • Round 2 (07d59a3d): the header's "Manage members" link is shown only in native mode.

Implementation plan for the set (hub cccvu/wiki-v2 PR 804): https://github.com/cccvu/wiki-v2/issues/797#issuecomment-6760267773

PMQ9 and others added 8 commits November 9, 2026 21:45
…ts only (INV-6) (docmost#797)

INV-4 (A4): a page grant never exceeds the acting human. Granting reader
needs their own page view, granting writer (add, or an update that raises)
needs page edit, or the workspace-admin disjunct (workspace#admin_cascade,
decided on the human only: a recorded exception to the docmost#617 intersection
rule). Decided under the page's ACL lock from the actor's own rows first;
the PDP's page answer only after a settle fence read under the lock, while
the transaction holds no xid. Refused: 403 grant_exceeds_actor, audited
page.acl_write_refused. A grant that passes only through the admin
disjunct is audited page.acl_admin_override_grant with the
PAGE_ACL_ADMIN_OVERRIDE log token. Fence unconfirmed: 503
grant_ceiling_unconfirmed. Lowering and removal stay open.

INV-6: a group subject on add or on a raise is 400
group_grant_not_allowed_on_restricted_page (the default group included,
INV-5). Existing group grants are grandfathered and reported by a
read-only keyset listing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…reads (wiki-v2 docmost#797)

Service bridge (CCC-owned, no upstream edits):
- ServiceGroupController/Service under /api/service/groups (groups:read /
  groups:write): list (q, limit), get, members (keyset, with externalId),
  memberships lookup, usage, create, rename, add members (1..200 user
  externalIds, provisioned like a space add, ON CONFLICT DO NOTHING),
  remove member (a narrowing route), delete (409 group_in_use while any
  live space membership or page grant names the group), and
  default/ensure (409 basic_group_has_grants, log token
  BASIC_GROUP_HAS_GRANTS). The default group is immutable elsewhere (409
  default_group_immutable).
- Space member add takes externalId XOR groupId and mode set|atLeast; the
  group branch locks the group row, applies rule M, upserts on
  (space_id, group_id), and refuses the default group (400
  basic_group_not_grantable, also on re-role).
- INV-2 (SpaceGrantCeiling): a write that raises a membership must be
  covered by the acting human (reader: space view; writer: edit and
  share; admin: a live direct admin row, own or through a group, or the
  workspace cascade). Local rows decide under the space lock first; the
  PDP is asked only after a settle fence read outside any transaction.
  403 grant_exceeds_actor, 503 grant_unconfirmed, 503 when the PDP
  cannot answer. Shared by the writes and the preview.

Authz:
- directoryRead remote-refusal family: native workspace members,
  invitations, group list/info/members and space members, 404 + audited.
- PdpSearchService returns group suggestions only to a workspace or space
  administrator.
- NARROWING_ROUTES: ServiceGroupController.removeMember.

Specs: real-Postgres group control plane, the full INV-2 matrix, a grant
racing a just-committed narrowing, INV-5 at each space sink, the group
branch, directory-read and group-subject fitness, contract and scope
coverage, all mutation-checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ilings (wiki-v2 docmost#797)

Bump service-bridge.openapi.json to 1.16.0 (F1 left the bump to the
integrator), name the space-member directory read in the refusal
sentence, and document the relayed page-ACL ceilings (INV-4/INV-6).
README: the groups family, a 1.16.0 section and the directoryRead
refusals, replacing the stale "reads stay reachable" line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…listing (wiki-v2 docmost#797)

The paged order is (created_at to the millisecond, id::text) and the
unpaged one (created_at, id), the same split as listSpaceMembers, so two
members added within one millisecond sorted differently and the spec
failed intermittently on the integration run. It now checks the keyset
pages against a single paged listing and the member set against the
unpaged one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ocmost#797 P2)

- Remote mode: the settings sidebar hides Members and Groups (the server's directoryRead
  refusal answers 404, so they showed empty tables; hiding also drops their hover prefetch),
  and the space Members tab renders only the Admin Console note, no empty member list.
- INV-6 in the UI: the restricted-page picker no longer offers groups (MultiMemberSelect
  includeGroups, default true), and a grandfathered group grant row offers only its current
  role or lower (the server refuses a raise).
- grant-ceiling-parity.spec.ts pins the schema facts the INV-2 / INV-4 local-row allows rely
  on (mirrored by the super repo's zed assertions); ROLE_RANK is exported for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… P2, review round 2)

The header's workspace menu linked every remote-mode user to /settings/members, which the
server's directoryRead refusal answers 404 (an empty table). The item now renders only in
native mode; pinned in feedback-menu.test.tsx (through the real TopMenu).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PMQ9
PMQ9 merged commit 1d8a155 into wiki-v2 Nov 10, 2026
@PMQ9
PMQ9 deleted the feat/797-p2-fork branch November 10, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant