Repository navigation
Hide add / re-role / invite / approve from collection admins the stakeholder gate refuses - #3295
Conversation
Code Review SummaryThis is a small, well-scoped change. The view's gating matches the tenant schema's enforcement, and I checked it against Server parity (verified against the schema):
Refusal mapping: The sync daemon forwards PostgREST's
Because both are BEFORE triggers, Reactivity: I ran FindingsCritical Issues
Suggested Improvements
Nitpicks
Verdict: APPROVE. Merge after |
Review responseThe review approves with no blockers. I'm not changing code in response, because every remaining point is wording:
|
…eholder gate refuses On an open collection only its creator or a workspace owner/admin may add another person, change their role, create an invite or approve a join request (ADR-037 §2a); the cloud refuses everyone else with 42501. The daemon's ListMembers now reports the server's stakeholder gate (always open on a restricted collection), carried through pro_list_members' RosterDto, the service's Roster and the store's per-collection stakeholderGate. CollaborationView offers those controls when the caller is a collection admin and the gate isn't a definite false; a refused admin keeps remove / revoke / reject, sees roles as badges, and is told who can manage the collection. An unknown gate (older daemon or cloud schema) hides nothing, and the cloud's refusals — stakeholder seed, stakeholder invite, creator-only admin grant — are mapped to actionable messages. Refreshes nodespace_pro.proto from nodespace-sync (additive optional field). Co-Authored-By: Claude Opus 5.5 <[email protected]>
184011a to
c044769
Compare
Closes #3294
Depends on cloud PR NodeSpaceAI/nodespace-cloud#200 and sync PR NodeSpaceAI/nodespace-sync#516. Merge order: cloud #200 → per-tenant rollout of
2026-09-29-stakeholder-self-check.sql→ sync #516 → this PR.What
On an open collection only its creator or an active workspace owner/admin may add another person, change their role, create an invite, or approve a join request (ADR-037 §2a, cloud #198). The cloud refuses everyone else with 42501. The collaboration view now hides those controls from collection admins that the server's stakeholder gate refuses.
Where the answer comes from: the desktop can't compute stakeholder status. It has neither the caller's Supabase uid nor the collection's server-stamped
created_by. Instead, the cloud answersstakeholder_gate_allows_me(collection)(cloud #200), and sync'sListMembersreturns it asoptional bool stakeholder_gate_allows_caller(sync #516). That's the call this view already makes, so there's no extra round trip.Gate semantics: the gate is always
trueon a restricted collection, because there the admin rule governs. SoamAdmin && gate !== falseequalsrestricted ? amAdmin : amAdmin && isStakeholder. The restricted flag is read authoritatively server-side, not from synced local state.Changes by file:
src-tauri/proto/nodespace_pro.proto: refreshed from sync SchemaService: Runtime Schema Synchronization and Nested Field Support #516. The change is additive: one proto3optionalfield.src-tauri/src/commands/pro_sync.rs:RosterDto { members, stakeholder_gate_allows_caller: Option<bool> }is built withFrom<ListMembersResponse>.pro_list_membersnow returns it.src/lib/services/membership-service.ts:listMembersreturnsRoster { members, stakeholderGateAllowsCaller: boolean | null }.null, neverfalse.src/lib/stores/membership.svelte.ts: each collection's cache gainsstakeholderGate(null= unknown), set on every roster load.collaboration-view.svelte:canManageOthers = amAdmin && view.stakeholderGate !== false.canManageOthers: the role select, the add-existing form, the create-invite row, and approving a join request (role picker plus Approve).approve_requestdelegates toset_member, so approving seeds another person, which the stakeholder limit covers.amAdmin: Remove, the invite list with Revoke, and Reject. These are deletes, which the stakeholder limit doesn't cover.friendly()maps the cloud's refusals.Older daemon / cloud schema not yet rolled out: there's no separate RPC, so there's no Unimplemented to handle. An older daemon never sets the field, and a new daemon on a tenant without the function (PGRST202), or with a failed or timed-out gate, leaves it unset. In every case the gate is
nulland nothing is hidden. If the server then refuses, the refusal is explained with the messages above.Tests
collaboration-view.test.ts), 10 scenarios, each asserting role select, add form, Create invite, Approve, approve-role, Remove, Revoke, Reject, the refusal note, and Leave:falsepasses through;nullor missing becomesnull.roster_dto_carries_members_and_the_stakeholder_gate, covering members,Some(true)/Some(false), andNoneserializing tonull.Mutations: all 17 killed.
amAdmin.canManageOthers.canManageOthers.false; S2 turnsfalseintonull.false.Gates:
bun run quality:fix: passes, including workspace clippy-D warnings -D clippy::unused-async.cargo clippy -p nodespace-app --all-targets -- -D warnings -D clippy::unused-async: clean.bun run test:changed: passes (frontend, scripts, browser, and Rust nextest).Follow-ups (not in this PR)
enforce_open_admin_grant). The desktop can't tell the creator from a workspace owner/admin, so the Admin option stays in the pickers, and a refused grant is explained. An email-bound admin invite on an open collection can be created but never redeemed. That predates this PR; it was found during review of cloud Optimize Embedding Re-generation: Granular Change Tracking & Single Background Processor #200.🤖 Generated with Claude Code